Skip to content

Commit 669a131

Browse files
committed
🎨 Improve how MediaQuery is being listened
1 parent ad65485 commit 669a131

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ that can be found in the LICENSE file. -->
99
1010
## Unreleased
1111

12-
*None.*
12+
**Improvements**
13+
14+
- Improve how `MediaQuery` is being listened.
1315

1416
## 9.5.1
1517

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
717717
/// The overlay when the permission is limited.
718718
Widget permissionOverlay(BuildContext context) {
719719
final Size size = MediaQuery.sizeOf(context);
720+
final EdgeInsets padding = MediaQuery.paddingOf(context);
720721
final Widget closeButton = Container(
721722
margin: const EdgeInsetsDirectional.only(start: 16, top: 4),
722723
alignment: AlignmentDirectional.centerStart,
@@ -793,7 +794,7 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
793794
child: Semantics(
794795
sortKey: const OrdinalSortKey(0),
795796
child: Container(
796-
padding: EdgeInsets.only(top: MediaQuery.paddingOf(context).top),
797+
padding: EdgeInsets.only(top: padding.top),
797798
color: context.theme.canvasColor,
798799
child: Column(
799800
children: <Widget>[
@@ -803,10 +804,7 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
803804
SizedBox(height: size.height / 18),
804805
accessLimitedButton,
805806
SizedBox(
806-
height: math.max(
807-
MediaQuery.paddingOf(context).bottom,
808-
24.0,
809-
),
807+
height: math.max(padding.bottom, 24.0),
810808
),
811809
],
812810
),
@@ -1317,6 +1315,7 @@ class DefaultAssetPickerBuilderDelegate
13171315
Widget assetsGridBuilder(BuildContext context) {
13181316
appBarPreferredSize ??= appBar(context).preferredSize;
13191317
final bool gridRevert = effectiveShouldRevertGrid(context);
1318+
final accessibleNavigation = MediaQuery.accessibleNavigationOf(context);
13201319
return Selector<DefaultAssetPickerProvider, PathWrapper<AssetPathEntity>?>(
13211320
selector: (_, DefaultAssetPickerProvider p) => p.currentPath,
13221321
builder: (context, wrapper, _) {
@@ -1374,8 +1373,7 @@ class DefaultAssetPickerBuilderDelegate
13741373
);
13751374

13761375
// Enables drag-to-select.
1377-
if (dragToSelect ??
1378-
!MediaQuery.accessibleNavigationOf(context)) {
1376+
if (dragToSelect ?? !accessibleNavigation) {
13791377
child = GestureDetector(
13801378
excludeFromSemantics: true,
13811379
onHorizontalDragStart: (d) {

lib/src/widget/asset_picker_app_bar.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget {
113113
} else {
114114
titleWidget = title;
115115
}
116+
117+
final EdgeInsets padding = MediaQuery.paddingOf(context);
116118
Widget child = Container(
117119
width: double.maxFinite,
118-
height: _barHeight + MediaQuery.paddingOf(context).top,
119-
padding: EdgeInsets.only(top: MediaQuery.paddingOf(context).top),
120+
height: _barHeight + padding.top,
121+
padding: EdgeInsets.only(top: padding.top),
120122
child: Stack(
121123
children: <Widget>[
122124
if (canPop(context))

0 commit comments

Comments
 (0)