[flutter_adaptive_scaffold] Changed type of `appBar` parameter from `AppBar?` to `PreferredSizeWidget?` (#2617)
diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md
index 70e4f65..20bb4c8 100644
--- a/packages/flutter_adaptive_scaffold/CHANGELOG.md
+++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.0.6
+
+* Change type of `appBar` parameter from `AppBar?` to `PreferredSizeWidget?`
+
## 0.0.5
* Calls onDestinationChanged callback in bottom nav bar.
diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
index 0521634..58509ff 100644
--- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
+++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
@@ -217,7 +217,7 @@
/// Option to override the default [AppBar] when using drawer in desktop
/// small.
- final AppBar? appBar;
+ final PreferredSizeWidget? appBar;
/// Callback function for when the index of a [NavigationRail] changes.
final Function(int)? onSelectedIndexChange;
diff --git a/packages/flutter_adaptive_scaffold/pubspec.yaml b/packages/flutter_adaptive_scaffold/pubspec.yaml
index 46ab151..59f6f67 100644
--- a/packages/flutter_adaptive_scaffold/pubspec.yaml
+++ b/packages/flutter_adaptive_scaffold/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_adaptive_scaffold
description: Widgets to easily build adaptive layouts, including navigation elements.
-version: 0.0.5
+version: 0.0.6
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_adaptive_scaffold%22
repository: https://github.com/flutter/packages/tree/main/packages/flutter_adaptive_scaffold
diff --git a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart
index 1b24b6b..4b8b632 100644
--- a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart
+++ b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart
@@ -168,6 +168,46 @@
expect(selectedIndex, state.index);
});
});
+
+ // Regression test for https://github.com/flutter/flutter/issues/111008
+ testWidgets(
+ 'appBar parameter should have the type PreferredSizeWidget',
+ (WidgetTester tester) async {
+ await tester.pumpWidget(MaterialApp(
+ home: MediaQuery(
+ data: const MediaQueryData(size: Size(500, 800)),
+ child: AdaptiveScaffold(
+ drawerBreakpoint: TestBreakpoint0(),
+ internalAnimations: false,
+ destinations: const <NavigationDestination>[
+ NavigationDestination(icon: Icon(Icons.inbox), label: 'Inbox'),
+ NavigationDestination(
+ icon: Icon(Icons.video_call), label: 'Video'),
+ ],
+ appBar: const PreferredSizeWidgetImpl(),
+ ),
+ ),
+ ));
+
+ expect(find.byType(PreferredSizeWidgetImpl), findsOneWidget);
+ },
+ );
+}
+
+/// An empty widget that implements [PreferredSizeWidget] to ensure that
+/// [PreferredSizeWidget] is used as [AdaptiveScaffold.appBar] parameter instead
+/// of [AppBar].
+class PreferredSizeWidgetImpl extends StatelessWidget
+ implements PreferredSizeWidget {
+ const PreferredSizeWidgetImpl({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return Container();
+ }
+
+ @override
+ Size get preferredSize => const Size(200, 200);
}
class TestBreakpoint0 extends Breakpoint {