From ef387583a04b38c2c42e63212d67bdd9440841f4 Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 10:08:42 +0000 Subject: [PATCH 01/12] changed selectedIndex on standardNavigationRail to allow null value --- .../flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart index e9ec85190c11..f777fe1bea00 100644 --- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart +++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart @@ -251,7 +251,7 @@ class AdaptiveScaffold extends StatefulWidget { static Builder standardNavigationRail({ required List destinations, double width = 72, - int selectedIndex = 0, + int? selectedIndex, bool extended = false, Color backgroundColor = Colors.transparent, EdgeInsetsGeometry padding = const EdgeInsets.all(8.0), From 8900332d1c4060f78cb1af71445a6d7ba755d3c0 Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 10:30:46 +0000 Subject: [PATCH 02/12] Update CHANGELOG.md --- packages/flutter_adaptive_scaffold/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index 88f6aa175bd9..eeb19e5b0419 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.1.0 + +* Change `selectIndex` on `standardNavigatioRail` to allow null value. + + ## 0.0.9 * Fix passthrough of `leadingExtendedNavRail`, `leadingUnextendedNavRail` and `trailingNavRail` From 22c8bd7e5ae2fa16cc8c27a78616ef34588c873d Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 10:31:08 +0000 Subject: [PATCH 03/12] increase version number --- packages/flutter_adaptive_scaffold/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_adaptive_scaffold/pubspec.yaml b/packages/flutter_adaptive_scaffold/pubspec.yaml index 33b0353283af..e3fcb67d3e1b 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.9 +version: 0.1.0 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 From e1d71f787176101f44cd308794b08332d165e3d0 Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 10:36:42 +0000 Subject: [PATCH 04/12] Update CHANGELOG.md --- packages/flutter_adaptive_scaffold/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index eeb19e5b0419..7fe735d1ff5d 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.1.0 -* Change `selectIndex` on `standardNavigatioRail` to allow null value. +* Change `selectedIndex` on `standardNavigatioRail` to allow null value. ## 0.0.9 From 31c3485a4261ce854b406687d2d80bca1ce3bd95 Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 10:37:27 +0000 Subject: [PATCH 05/12] Update CHANGELOG.md --- packages/flutter_adaptive_scaffold/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index 7fe735d1ff5d..d209e49edda8 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.1.0 -* Change `selectedIndex` on `standardNavigatioRail` to allow null value. +* Change `selectedIndex` on `standardNavigationRail` to allow null value. ## 0.0.9 From 03a17513ee42e135263f98b63806cbce36e23201 Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 11:13:50 +0000 Subject: [PATCH 06/12] change index types from int to int? --- .../flutter_adaptive_scaffold/test/simulated_layout.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/flutter_adaptive_scaffold/test/simulated_layout.dart b/packages/flutter_adaptive_scaffold/test/simulated_layout.dart index e81a5ff1aacf..ae68715cc028 100644 --- a/packages/flutter_adaptive_scaffold/test/simulated_layout.dart +++ b/packages/flutter_adaptive_scaffold/test/simulated_layout.dart @@ -36,7 +36,7 @@ class TestScaffold extends StatefulWidget { this.isAnimated = true, }); - final int initialIndex; + final int? initialIndex; final bool isAnimated; static const List destinations = @@ -63,7 +63,7 @@ class TestScaffold extends StatefulWidget { } class TestScaffoldState extends State { - late int index = widget.initialIndex; + late int? index = widget.initialIndex; @override Widget build(BuildContext context) { @@ -110,7 +110,7 @@ enum SimulatedLayout { Size get size => Size(_width, _height); MaterialApp app({ - int initialIndex = 0, + int? initialIndex, bool animations = true, }) { return MaterialApp( From df4a67fdecea891beb480b50369d5a34ddad3d8a Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 11:14:28 +0000 Subject: [PATCH 07/12] add test for slectedIndex can be set to null --- .../test/adaptive_scaffold_test.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart index 36a451ca0845..7e3e46b44e4f 100644 --- a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart +++ b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_adaptive_scaffold/src/adaptive_scaffold.dart'; import 'package:flutter_test/flutter_test.dart'; + import 'simulated_layout.dart'; import 'test_breakpoints.dart'; @@ -222,6 +223,22 @@ void main() { }); }, ); + + /// Verify that selectedIndex of [AdaptiveScaffold.standardNavigationRail] + /// and [AdaptiveScaffold] can be set to null + testWidgets( + 'adaptive scaffold selectedIndex can be set to null', + (WidgetTester tester) async { + await Future.forEach(SimulatedLayout.values, + (SimulatedLayout region) async { + int? selectedIndex; + final MaterialApp app = region.app(initialIndex: selectedIndex); + await tester.binding.setSurfaceSize(region.size); + await tester.pumpWidget(app); + await tester.pumpAndSettle(); + }); + }, + ); } /// An empty widget that implements [PreferredSizeWidget] to ensure that From b61e228c9be29e5b137d1738f1352f25e62c950e Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 11:14:32 +0000 Subject: [PATCH 08/12] Update CHANGELOG.md --- packages/flutter_adaptive_scaffold/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index d209e49edda8..af6a09426a1a 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.1.0 * Change `selectedIndex` on `standardNavigationRail` to allow null value. +* A null `selectIndex` applied to `standardBottomNavigationBar` will be set to -1. ## 0.0.9 From ca1d495fa6bfcfcec621f85a4fbefd7508af0b28 Mon Sep 17 00:00:00 2001 From: Joshua Davis Date: Wed, 25 Jan 2023 11:15:16 +0000 Subject: [PATCH 09/12] index types set to int? and ensure BottomNavigationRail currentIndex isn't null --- .../lib/src/adaptive_scaffold.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart index f777fe1bea00..62eba1d2f073 100644 --- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart +++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart @@ -110,7 +110,7 @@ class AdaptiveScaffold extends StatefulWidget { final List destinations; /// The index to be used by the [NavigationRail]. - final int selectedIndex; + final int? selectedIndex; /// Option to display a leading widget at the top of the navigation rail /// at the middle breakpoint. @@ -305,14 +305,15 @@ class AdaptiveScaffold extends StatefulWidget { /// a list of [NavigationDestination]s. static Builder standardBottomNavigationBar({ required List destinations, - int currentIndex = 0, + int? currentIndex, double iconSize = 24, ValueChanged? onDestinationSelected, }) { + currentIndex ??= 0; return Builder( builder: (_) { return BottomNavigationBar( - currentIndex: currentIndex, + currentIndex: currentIndex!, iconSize: iconSize, items: destinations .map((NavigationDestination e) => _toBottomNavItem(e)) From de99a6414b398ae6020f29c6d94798534bf83a4a Mon Sep 17 00:00:00 2001 From: Joshua Davis <114495200+joshryandavis@users.noreply.github.com> Date: Wed, 25 Jan 2023 20:42:58 +0000 Subject: [PATCH 10/12] Update packages/flutter_adaptive_scaffold/CHANGELOG.md Co-authored-by: Greg Spencer --- packages/flutter_adaptive_scaffold/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index af6a09426a1a..b88321da0ecd 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.1.0 -* Change `selectedIndex` on `standardNavigationRail` to allow null value. +* Change the `selectedIndex` parameter on `standardNavigationRail` to allow null values to indicate "no destination". * A null `selectIndex` applied to `standardBottomNavigationBar` will be set to -1. From 093011e9938ce417a716716158f1aedda68657c5 Mon Sep 17 00:00:00 2001 From: Joshua Davis <114495200+joshryandavis@users.noreply.github.com> Date: Wed, 25 Jan 2023 20:43:05 +0000 Subject: [PATCH 11/12] Update packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart Co-authored-by: Greg Spencer --- .../flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart index 62eba1d2f073..8a7e37e8fa01 100644 --- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart +++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart @@ -313,7 +313,7 @@ class AdaptiveScaffold extends StatefulWidget { return Builder( builder: (_) { return BottomNavigationBar( - currentIndex: currentIndex!, + currentIndex: currentIndex ?? 0, iconSize: iconSize, items: destinations .map((NavigationDestination e) => _toBottomNavItem(e)) From ccb67457bf5e710ff995e381750aa753a98cfa40 Mon Sep 17 00:00:00 2001 From: Joshua Davis <114495200+joshryandavis@users.noreply.github.com> Date: Wed, 25 Jan 2023 20:43:11 +0000 Subject: [PATCH 12/12] Update packages/flutter_adaptive_scaffold/CHANGELOG.md Co-authored-by: Greg Spencer --- packages/flutter_adaptive_scaffold/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index b88321da0ecd..65d360cc07ee 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.1.0 * Change the `selectedIndex` parameter on `standardNavigationRail` to allow null values to indicate "no destination". -* A null `selectIndex` applied to `standardBottomNavigationBar` will be set to -1. +* An explicitly null `currentIndex` parameter passed to `standardBottomNavigationBar` will also default to 0, just like implicitly null missing parameters. ## 0.0.9