No Description

main.dart 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:flutter/material.dart';
  2. import 'package:photo/photo.dart';
  3. import 'package:photo_manager/photo_manager.dart';
  4. void main() => runApp(new MyApp());
  5. class MyApp extends StatelessWidget {
  6. // This widget is the root of your application.
  7. @override
  8. Widget build(BuildContext context) {
  9. return new MaterialApp(
  10. title: 'Pick Image Demo',
  11. theme: new ThemeData(
  12. primarySwatch: Colors.blue,
  13. ),
  14. home: new MyHomePage(title: 'Pick Image Demo'),
  15. );
  16. }
  17. }
  18. class MyHomePage extends StatefulWidget {
  19. MyHomePage({Key key, this.title}) : super(key: key);
  20. final String title;
  21. @override
  22. _MyHomePageState createState() => new _MyHomePageState();
  23. }
  24. class _MyHomePageState extends State<MyHomePage> {
  25. String currentSelected = "";
  26. void _pickImage() async {
  27. List<ImageEntity> imgList = await PhotoPicker.pickImage(
  28. context: context,
  29. themeColor: Colors.green,
  30. padding: 5.0,
  31. dividerColor: Colors.deepOrange,
  32. disableColor: Colors.grey.shade300,
  33. itemRadio: 0.88,
  34. maxSelected: 8,
  35. provider: CNProvider(),
  36. rowCount: 5,
  37. textColor: Colors.white,
  38. thumbSize: 250,
  39. );
  40. List<String> r = [];
  41. for(var e in imgList){
  42. var file = await e.file;
  43. r.add(file.absolute.path);
  44. }
  45. currentSelected = r.join("\n\n");
  46. setState(() {});
  47. }
  48. @override
  49. Widget build(BuildContext context) {
  50. return new Scaffold(
  51. appBar: new AppBar(
  52. title: new Text(widget.title),
  53. ),
  54. body: Container(
  55. child: Center(
  56. child: Text('$currentSelected'),
  57. ),
  58. ),
  59. floatingActionButton: new FloatingActionButton(
  60. onPressed: _pickImage,
  61. tooltip: 'pickImage',
  62. child: new Icon(Icons.add),
  63. ),
  64. );
  65. }
  66. }