Upload Mutiple image to AWS s3 bucket using Simple S3

Hi i am doing a multiple image upload in AWS s3 bucket using simple_s3 plugin, but the code is looping after uploaded and again uploading a image for single image, if two or more images selected and uploaded then first image uploaded and other doesn’t upload and app closes.
Code given below, plz help me it is urgent.

import ‘dart:io’;

import ‘package:flutter/material.dart’;
import ‘dart:async’;
import ‘package:simple_s3/simple_s3.dart’;
import ‘package:image_picker/image_picker.dart’;

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State {
List images = [];
String _error = ‘No Error Dectected’;
SimpleS3 _simpleS3 = SimpleS3();
bool isLoading = false;
bool uploaded = false;

@override
void initState() {
super.initState();
}

Widget buildGridView() {
return GridView.count(
crossAxisCount: 3,
children: List.generate(images.length, (index) {
print(“length od lost” +images[index].path);
File asset =File(images[index].path);
print(asset);

    _upload(asset);

    // _upload(asset);
    return Container(
      child: Stack(
        children: [
          //AssetThumb
          Container(
            child: Image.file(asset),
            width: 300,
            height: 300,
          ),
          uploaded?Container(padding:EdgeInsets.only(left: 110.0,top: 8.0),child:Icon(Icons.delete,color: Colors.red,)):Container(),
          isLoading?CircularProgressIndicator():Container()
          // isLoading?StreamBuilder<dynamic>(
          //     stream: _simpleS3.getUploadPercentage,
          //     builder: (context, snapshot) {
          //       print(snapshot.data);
          //       return snapshot.data!=null?Container(height:270,width:280,child: LinearProgressIndicator(value:snapshot.data.toDouble() ,color: Colors.blue,backgroundColor:Colors.white,),):Container();
          //     }):Container(),

          // Container(child: LinearProgressIndicator(value: ,color: Colors.blue,backgroundColor:Colors.white ,),),
          // Center(child: Text("99%",style: TextStyle(color: Colors.white)),)
        ],
      ),
    );

  }),
);

}
Future<String?> _upload(File asset) async {
String? result;
print(“upload”+asset.path);
if (result == null) {

  try {
    setState(() {
      isLoading = true;
    });
    result = await _simpleS3.uploadFile(
      asset,
      "bucket_name",
      "pool_id",
      AWSRegions.usEast1,
      debugLog: true,
      s3FolderPath: "test",
      accessControl: S3AccessControl.private,
    );
    if(result!=null){
    setState(() {
      uploaded = true;
      isLoading = false;
    });}
  } catch (e) {
    print(e);
  }
}
return result;

}

Future loadAssets() async {
List resultList = [];
String error = ‘No Error Detected’;

try {
  resultList = (await ImagePicker().pickMultiImage())!;
  images = resultList;
} on Exception catch (e) {
  error = e.toString();
}

// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;

setState(() {
  images = resultList;
  _error = error;
});

}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text(‘Plugin example app’),
),
body: Column(
children: [
Center(child: Text(‘Error: $_error’)),
ElevatedButton(
child: Text(“Pick images”),
onPressed: loadAssets,
),
Expanded(
child: buildGridView(),
)
],
),
),
);
}
}