In this article we will learn about some of the frequently asked TypeScript programming questions in technical like “flutter ui upload multiple image” Code Answer’s. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on typescript was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in Typescript. Below are some solution about “flutter ui upload multiple image” Code Answer’s.
flutter ui upload multiple image
xxxxxxxxxx
1
import 'package:flutter/material.dart';
2
import 'dart:async';
3
4
import 'package:multi_image_picker/multi_image_picker.dart';
5
6
void main() => runApp(new MyApp());
7
8
class MyApp extends StatefulWidget {
9
@override
10
_MyAppState createState() => new _MyAppState();
11
}
12
13
class _MyAppState extends State<MyApp> {
14
List<Asset> images = List<Asset>();
15
String _error = 'Selectionner une image';
16
17
@override
18
void initState() {
19
super.initState();
20
}
21
22
Widget buildGridView() {
23
return GridView.count(
24
crossAxisCount: 3,
25
children: List.generate(images.length, (index) {
26
Asset asset = images[index];
27
return AssetThumb(
28
asset: asset,
29
width: 300,
30
height: 300,
31
);
32
}),
33
);
34
}
35
36
Future<void> loadAssets() async {
37
List<Asset> resultList = List<Asset>();
38
String error = 'No Error Dectected';
39
40
try {
41
resultList = await MultiImagePicker.pickImages(
42
maxImages: 4,
43
enableCamera: true,
44
selectedAssets: images,
45
cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"),
46
materialOptions: MaterialOptions(
47
actionBarColor: "#abcdef",
48
actionBarTitle: "Example App",
49
allViewTitle: "All Photos",
50
useDetailsView: false,
51
selectCircleStrokeColor: "#000000",
52
),
53
);
54
} on Exception catch (e) {
55
error = e.toString();
56
}
57
58
// If the widget was removed from the tree while the asynchronous platform
59
// message was in flight, we want to discard the reply rather than calling
60
// setState to update our non-existent appearance.
61
if (!mounted) return;
62
63
setState(() {
64
images = resultList;
65
_error = error;
66
});
67
}
68
69
@override
70
Widget build(BuildContext context) {
71
return new MaterialApp(
72
home: new Scaffold(
73
appBar: new AppBar(
74
xxxxxxxxxx
1import 'dart:io';
2
3//import 'package:blog_app/models/ImageUploadModel.dart';
4import 'package:flutter/material.dart';
5import 'package:image_picker/image_picker.dart';
6
7class SingleImageUpload extends StatefulWidget {
8@override
9_SingleImageUploadState createState() {
10return _SingleImageUploadState();
11}
12}
13
14class _SingleImageUploadState extends State<SingleImageUpload> {
15List<Object> images = List<Object>();
16Future<File> _imageFile;
17@override
18void initState() {
19// TODO: implement initState
20super.initState();
21setState(() {
22images.add("Add Image");
23images.add("Add Image");
24// images.add("Add Image");
25// images.add("Add Image");
26});
27}
28
29@override
30Widget build(BuildContext context) {
31return new MaterialApp(
32home: new Scaffold(
33appBar: new AppBar(
34centerTitle: true,
35title: const Text('Upload image'),
36),
37body: Column(
38children: <Widget>[
39Expanded(
40child: buildGridView(),
41),
42],
43),
44),
45);
46}
47
48Widget buildGridView() {
49return GridView.count(
50shrinkWrap: true,
51crossAxisCount: 3,
52childAspectRatio: 1,
53children: List.generate(images.length, (index) {
54if (images[index] is ImageUploadModel) {
55ImageUploadModel uploadModel = images[index];
56return Card(
57clipBehavior: Clip.antiAlias,
58child: Stack(
59children: <Widget>[
60Image.file(
61uploadModel.imageFile,
62width: 300,
63height: 300,
64),
65Positioned(
66right: 5,
67top: 5,
68child: InkWell(
69child: Icon(
70Icons.remove_circle,
71size: 20,
72color: Colors.red,
73),
74onTap: () {
75setState
flutter ui upload multiple image
xxxxxxxxxx
1import 'package:flutter/material.dart';
2import 'dart:async';
3
4import 'package:multi_image_picker/multi_image_picker.dart';
5
6void main() => runApp(new MyApp());
7
8class MyApp extends StatefulWidget {
9@override
10_MyAppState createState() => new _MyAppState();
11}
12
13class _MyAppState extends State<MyApp> {
14List<Asset> images = List<Asset>();
15String _error;
16
17@override
18void initState() {
19super.initState();
20}
21
22Widget buildGridView() {
23if (images != null)
24return GridView.count(
25crossAxisCount: 3,
26children: List.generate(images.length, (index) {
27Asset asset = images[index];
28return AssetThumb(
29asset: asset,
30width: 300,
31height: 300,
32);
33}),
34);
35else
36return Container(color: Colors.white);
37}
38
39Future<void> loadAssets() async {
40setState(() {
41images = List<Asset>();
42});
43
44List<Asset> resultList;
45String error;
46
47try {
48resultList = await MultiImagePicker.pickImages(
49maxImages: 300,
50);
51} on Exception catch (e) {
52error = e.toString();
53}
54
55// If the widget was removed from the tree while the asynchronous platform
56// message was in flight, we want to discard the reply rather than calling
57// setState to update our non-existent appearance.
58if (!mounted) return;
59
60setState(() {
61images = resultList;
62if (error == null) _error = 'No Error Dectected';
63});
64}
65
66@override
67Widget build(BuildContext context) {
68return new MaterialApp(
69home: new Scaffold(
70appBar: new AppBar(
71title: const Text('Plugin example app'),
72),
73body: Column(
74children: <Widget