Sin descripción

main.dart 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. );
  39. List<String> r = [];
  40. for(var e in imgList){
  41. var file = await e.file;
  42. r.add(file.absolute.path);
  43. }
  44. currentSelected = r.join("\n\n");
  45. setState(() {});
  46. }
  47. @override
  48. Widget build(BuildContext context) {
  49. return new Scaffold(
  50. appBar: new AppBar(
  51. title: new Text(widget.title),
  52. ),
  53. body: Container(
  54. child: Center(
  55. child: Text('$currentSelected'),
  56. ),
  57. ),
  58. floatingActionButton: new FloatingActionButton(
  59. onPressed: _pickImage,
  60. tooltip: 'pickImage',
  61. child: new Icon(Icons.add),
  62. ),
  63. );
  64. }
  65. }