No Description

picked_example.dart 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:photo/photo.dart';
  4. import 'icon_text_button.dart';
  5. import 'package:photo_manager/photo_manager.dart';
  6. class PickedExample extends StatefulWidget {
  7. @override
  8. _PickedExampleState createState() => _PickedExampleState();
  9. }
  10. class _PickedExampleState extends State<PickedExample> {
  11. List<AssetEntity> picked = [];
  12. @override
  13. Widget build(BuildContext context) {
  14. return Scaffold(
  15. appBar: AppBar(
  16. title: Text("Cross Picked asset"),
  17. ),
  18. body: Column(
  19. children: <Widget>[
  20. IconTextButton(
  21. icon: Icons.assignment,
  22. text: "Pick asset",
  23. onTap: _pickAsset,
  24. ),
  25. ListTile(
  26. title: Text("picked asset count = ${picked.length}"),
  27. ),
  28. ],
  29. ),
  30. );
  31. }
  32. void _pickAsset() async {
  33. final result = await PhotoPicker.pickAsset(
  34. context: context,
  35. pickedAssetList: picked,
  36. );
  37. if (result != null && result.isNotEmpty) {
  38. picked.clear();
  39. picked.addAll(result);
  40. setState(() {});
  41. }
  42. }
  43. }