@@ -65,7 +65,7 @@ class _DirectoryFileAssetPickerState extends State<DirectoryFileAssetPicker> {
65
65
}
66
66
}
67
67
68
- Widget get selectedAssetsWidget {
68
+ Widget selectedAssetsWidget ( BuildContext context) {
69
69
return AnimatedContainer (
70
70
duration: kThemeChangeDuration,
71
71
curve: Curves .easeInOut,
@@ -118,20 +118,21 @@ class _DirectoryFileAssetPickerState extends State<DirectoryFileAssetPicker> {
118
118
),
119
119
),
120
120
),
121
- selectedAssetsListView,
121
+ selectedAssetsListView (context) ,
122
122
],
123
123
),
124
124
);
125
125
}
126
126
127
- Widget get selectedAssetsListView {
127
+ Widget selectedAssetsListView ( BuildContext context) {
128
128
return Expanded (
129
129
child: ListView .builder (
130
+ shrinkWrap: true ,
130
131
physics: const BouncingScrollPhysics (),
131
132
padding: const EdgeInsets .symmetric (horizontal: 8.0 ),
132
133
scrollDirection: Axis .horizontal,
133
134
itemCount: fileList.length,
134
- itemBuilder: (BuildContext _, int index) {
135
+ itemBuilder: (_, int index) {
135
136
return Padding (
136
137
padding: const EdgeInsets .symmetric (
137
138
horizontal: 8.0 ,
@@ -269,7 +270,7 @@ class _DirectoryFileAssetPickerState extends State<DirectoryFileAssetPicker> {
269
270
),
270
271
),
271
272
),
272
- selectedAssetsWidget,
273
+ selectedAssetsWidget (context) ,
273
274
],
274
275
),
275
276
);
@@ -290,17 +291,15 @@ class FileAssetPickerProvider extends AssetPickerProvider<File, Directory> {
290
291
Future <void > getPaths () async {
291
292
currentAssets = < File > [];
292
293
paths.clear ();
293
- final Directory ? directory = await getExternalStorageDirectory ();
294
- if (directory != null ) {
295
- final PathWrapper <Directory > wrapper = PathWrapper <Directory >(
296
- path: directory,
297
- thumbnailData: await getThumbnailFromPath (
298
- PathWrapper <Directory >(path: directory),
299
- ),
300
- );
301
- paths.add (wrapper);
302
- currentPath = wrapper;
303
- }
294
+ final Directory directory = await getApplicationDocumentsDirectory ();
295
+ final PathWrapper <Directory > wrapper = PathWrapper <Directory >(
296
+ path: directory,
297
+ thumbnailData: await getThumbnailFromPath (
298
+ PathWrapper <Directory >(path: directory),
299
+ ),
300
+ );
301
+ paths.add (wrapper);
302
+ currentPath = wrapper;
304
303
}
305
304
306
305
@override
@@ -501,7 +500,7 @@ class FileAssetPickerBuilder
501
500
502
501
@override
503
502
PreferredSizeWidget appBar (BuildContext context) {
504
- return AppBar (
503
+ final AppBar appBar = AppBar (
505
504
backgroundColor: theme.appBarTheme.backgroundColor,
506
505
centerTitle: isAppleOS (context),
507
506
title: pathEntitySelector (context),
@@ -513,6 +512,8 @@ class FileAssetPickerBuilder
513
512
]
514
513
: null ,
515
514
);
515
+ appBarPreferredSize ?? = appBar.preferredSize;
516
+ return appBar;
516
517
}
517
518
518
519
@override
@@ -555,7 +556,7 @@ class FileAssetPickerBuilder
555
556
},
556
557
),
557
558
),
558
- appBar (context),
559
+ Positioned . fill (bottom : null , child : appBar (context) ),
559
560
],
560
561
);
561
562
}
@@ -585,6 +586,7 @@ class FileAssetPickerBuilder
585
586
586
587
@override
587
588
Widget assetsGridBuilder (BuildContext context) {
589
+ appBarPreferredSize ?? = appBar (context).preferredSize;
588
590
int totalCount = provider.currentAssets.length;
589
591
if (specialItemPosition != SpecialItemPosition .none) {
590
592
totalCount += 1 ;
@@ -598,7 +600,7 @@ class FileAssetPickerBuilder
598
600
final int row = (totalCount + placeholderCount) ~ / gridCount;
599
601
final double dividedSpacing = itemSpacing / gridCount;
600
602
final double topPadding =
601
- MediaQuery .of (context).padding. top + kToolbarHeight ;
603
+ MediaQuery .paddingOf (context).top + appBarPreferredSize ! .height ;
602
604
603
605
Widget sliverGrid (BuildContext ctx, List <File > assets) {
604
606
return SliverGrid (
@@ -670,16 +672,16 @@ class FileAssetPickerBuilder
670
672
if (isAppleOS (context))
671
673
SliverToBoxAdapter (
672
674
child: SizedBox (
673
- height:
674
- MediaQuery . of (context).padding.top + kToolbarHeight ,
675
+ height: MediaQuery . paddingOf (context).top +
676
+ appBarPreferredSize ! .height ,
675
677
),
676
678
),
677
679
sliverGrid (_, assets),
678
680
// Ignore the gap when the [anchor] is not equal to 1.
679
681
if (isAppleOS (context) && anchor == 1 )
680
682
SliverToBoxAdapter (
681
683
child: SizedBox (
682
- height: MediaQuery .of (context).padding .bottom +
684
+ height: MediaQuery .paddingOf (context).bottom +
683
685
bottomSectionHeight,
684
686
),
685
687
),
@@ -822,8 +824,9 @@ class FileAssetPickerBuilder
822
824
823
825
@override
824
826
Widget pathEntityListWidget (BuildContext context) {
827
+ appBarPreferredSize ?? = appBar (context).preferredSize;
825
828
final double appBarHeight =
826
- kToolbarHeight + MediaQuery .paddingOf (context).top;
829
+ appBarPreferredSize ! .height + MediaQuery .paddingOf (context).top;
827
830
final double maxHeight = MediaQuery .sizeOf (context).height * 0.825 ;
828
831
return ValueListenableBuilder <bool >(
829
832
valueListenable: isSwitchingPath,
@@ -1412,28 +1415,30 @@ class FileAssetPickerViewerBuilderDelegate
1412
1415
return Theme (
1413
1416
data: themeData,
1414
1417
child: AnnotatedRegion <SystemUiOverlayStyle >(
1415
- value: themeData.brightness == Brightness .dark
1418
+ value: themeData.brightness.reverse == Brightness .dark
1416
1419
? SystemUiOverlayStyle .light
1417
1420
: SystemUiOverlayStyle .dark,
1418
- child: Material (
1419
- color: Colors .black,
1420
- child: Stack (
1421
- children: < Widget > [
1422
- Positioned .fill (
1423
- child: PageView .builder (
1424
- physics: const BouncingScrollPhysics (),
1425
- controller: _pageController,
1426
- itemCount: previewAssets.length,
1427
- itemBuilder: assetPageBuilder,
1428
- onPageChanged: (int index) {
1429
- currentIndex = index;
1430
- pageStreamController.add (index);
1431
- },
1421
+ child: Builder (
1422
+ builder: (BuildContext context) => Material (
1423
+ color: Colors .black,
1424
+ child: Stack (
1425
+ children: < Widget > [
1426
+ Positioned .fill (
1427
+ child: PageView .builder (
1428
+ physics: const BouncingScrollPhysics (),
1429
+ controller: _pageController,
1430
+ itemCount: previewAssets.length,
1431
+ itemBuilder: assetPageBuilder,
1432
+ onPageChanged: (int index) {
1433
+ currentIndex = index;
1434
+ pageStreamController.add (index);
1435
+ },
1436
+ ),
1432
1437
),
1433
- ),
1434
- appBar (context),
1435
- if (selectedAssets != null ) bottomDetailBuilder (context) ,
1436
- ] ,
1438
+ appBar (context ),
1439
+ if (selectedAssets != null ) bottomDetailBuilder (context),
1440
+ ] ,
1441
+ ) ,
1437
1442
),
1438
1443
),
1439
1444
),
0 commit comments