Skip to content

Commit 94140f7

Browse files
committed
🎨 Improve app bar's type definition
1 parent 874833e commit 94140f7

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

example/lib/pages/custom_picker_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ class FileAssetPickerBuilder
463463
}
464464

465465
@override
466-
Widget appBar(BuildContext context) {
466+
PreferredSizeWidget appBar(BuildContext context) {
467467
return AppBar(
468468
backgroundColor: theme.appBarTheme.color,
469469
centerTitle: isAppleOS,

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ abstract class AssetPickerBuilderDelegate<A, P> {
382382

383383
/// Custom app bar for the picker.
384384
/// 选择器自定义的顶栏
385-
Widget appBar(BuildContext context);
385+
PreferredSizeWidget appBar(BuildContext context);
386386

387387
/// Layout for Apple OS devices.
388388
/// 苹果系列设备的选择器布局
@@ -509,7 +509,7 @@ class DefaultAssetPickerBuilderDelegate
509509
}
510510

511511
@override
512-
FixedAppBar appBar(BuildContext context) {
512+
PreferredSizeWidget appBar(BuildContext context) {
513513
return FixedAppBar(
514514
backgroundColor: theme.appBarTheme.color,
515515
centerTitle: isAppleOS,

lib/src/widget/fixed_appbar.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class FixedAppBarWrapper extends StatelessWidget {
173173
required this.body,
174174
}) : super(key: key);
175175

176-
final FixedAppBar appBar;
176+
final PreferredSizeWidget appBar;
177177
final Widget body;
178178

179179
@override
@@ -183,15 +183,15 @@ class FixedAppBarWrapper extends StatelessWidget {
183183
child: Stack(
184184
children: <Widget>[
185185
Positioned.fill(
186-
top: kToolbarHeight + MediaQuery.of(context).padding.top,
187-
child: body,
188-
),
189-
PositionedDirectional(
190-
top: 0.0,
191-
start: 0.0,
192-
end: 0.0,
193-
child: appBar,
186+
top: MediaQuery.of(context).padding.top +
187+
appBar.preferredSize.height,
188+
child: MediaQuery.removePadding(
189+
context: context,
190+
removeTop: true,
191+
child: body,
192+
),
194193
),
194+
Positioned.fill(bottom: null, child: appBar),
195195
],
196196
),
197197
);

0 commit comments

Comments
 (0)