1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import 'package:flutter/material.dart';
- import 'package:photo/photo.dart';
- import 'package:photo_manager/photo_manager.dart';
-
- void main() => runApp(new MyApp());
-
- class MyApp extends StatelessWidget {
-
- @override
- Widget build(BuildContext context) {
- return new MaterialApp(
- title: 'Pick Image Demo',
- theme: new ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: new MyHomePage(title: 'Pick Image Demo'),
- );
- }
- }
-
- class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
- final String title;
-
- @override
- _MyHomePageState createState() => new _MyHomePageState();
- }
-
- class _MyHomePageState extends State<MyHomePage> {
- String currentSelected = "";
-
- void _pickImage() async {
- List<AssetEntity> imgList = await PhotoPicker.pickImage(
- context: context,
-
-
- themeColor: Colors.green,
- padding: 1.0,
- dividerColor: Colors.grey,
- disableColor: Colors.grey.shade300,
- itemRadio: 0.88,
- maxSelected: 8,
- provider: I18nProvider
- .chinese,
- rowCount: 5,
- textColor: Colors.white,
- thumbSize: 150,
- sortDelegate: SortDelegate
- .common,
- checkBoxBuilderDelegate:
- DefaultCheckBoxBuilderDelegate(
- activeColor: Colors.white,
- unselectedColor: Colors.white,
- ),
- );
-
- if (imgList == null) {
- currentSelected = "not select item";
- } else {
- List<String> r = [];
- for (var e in imgList) {
- var file = await e.file;
- r.add(file.absolute.path);
- }
- currentSelected = r.join("\n\n");
- }
- setState(() {});
- }
-
- @override
- Widget build(BuildContext context) {
- return new Scaffold(
- appBar: new AppBar(
- title: new Text(widget.title),
- ),
- body: Container(
- child: Center(
- child: Text(
- '$currentSelected',
- textAlign: TextAlign.center,
- ),
- ),
- ),
- floatingActionButton: new FloatingActionButton(
- onPressed: _pickImage,
- tooltip: 'pickImage',
- child: new Icon(Icons.add),
- ),
- );
- }
- }
|