-
Notifications
You must be signed in to change notification settings - Fork 21
/
UploadFileDemo.dart
79 lines (72 loc) · 2.37 KB
/
UploadFileDemo.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import 'package:flutter/material.dart';
import 'package:flutter_templet_project/basicWidget/upload/asset_upload_box.dart';
import 'package:flutter_templet_project/basicWidget/upload_document/asset_upload_document_box.dart';
import 'package:flutter_templet_project/basicWidget/upload_document/asset_upload_document_model.dart';
import 'package:flutter_templet_project/util/color_util.dart';
import 'package:image_picker/image_picker.dart';
class UploadFileDemo extends StatefulWidget {
UploadFileDemo({Key? key, this.title}) : super(key: key);
final String? title;
@override
_UploadFileDemoState createState() => _UploadFileDemoState();
}
class _UploadFileDemoState extends State<UploadFileDemo> {
/// 初始化数据
var selectedModels = <AssetUploadDocumentModel>[];
/// 获取图片链接数组
List<String> urls = [];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
iconTheme: const IconThemeData(
color: fontColor,
// size: 20,
),
elevation: 0,
shadowColor: const Color(0xffe4e4e4),
title: Text(widget.title ?? "$widget"),
titleTextStyle: const TextTheme(
titleMedium: TextStyle(
// headline6 is used for setting title's theme
color: fontColor,
fontWeight: FontWeight.bold,
fontSize: 18,
),
).titleMedium,
toolbarTextStyle: const TextTheme(
titleMedium: TextStyle(
// headline6 is used for setting title's theme
color: fontColor,
fontWeight: FontWeight.bold,
fontSize: 18,
),
).titleMedium,
),
body: buildBody(),
);
}
buildBody() {
return SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: AssetUploadDocumentBox(
items: selectedModels,
// showFileSize: true,
onChanged: (items) {
selectedModels = items
.where((e) => e.url?.startsWith("http") == true)
.toList();
urls = selectedModels.map((e) => e.url ?? "").toList();
},
),
),
],
),
);
}
}