[flutter_adaptive_scaffold] Change `selectedIndex` on `standardNavigationRail` to allow null value. (#3088)

* changed selectedIndex on standardNavigationRail to allow null value

* Update CHANGELOG.md

* increase version number

* Update CHANGELOG.md

* Update CHANGELOG.md

* change index types from int to int?

* add test for slectedIndex can be set to null

* Update CHANGELOG.md

* index types set to int? and ensure BottomNavigationRail currentIndex isn't null

* Update packages/flutter_adaptive_scaffold/CHANGELOG.md

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>

* Update packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>

* Update packages/flutter_adaptive_scaffold/CHANGELOG.md

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>
diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md
index 88f6aa1..65d360c 100644
--- a/packages/flutter_adaptive_scaffold/CHANGELOG.md
+++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 0.1.0
+
+* Change the `selectedIndex` parameter on `standardNavigationRail` to allow null values to indicate "no destination".
+* An explicitly null `currentIndex` parameter passed to `standardBottomNavigationBar` will also default to 0, just like implicitly null missing parameters.
+
+
 ## 0.0.9
 
 * Fix passthrough of `leadingExtendedNavRail`, `leadingUnextendedNavRail` and `trailingNavRail`
diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
index e9ec851..8a7e37e 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 @@
   final List<NavigationDestination> 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.
@@ -251,7 +251,7 @@
   static Builder standardNavigationRail({
     required List<NavigationRailDestination> destinations,
     double width = 72,
-    int selectedIndex = 0,
+    int? selectedIndex,
     bool extended = false,
     Color backgroundColor = Colors.transparent,
     EdgeInsetsGeometry padding = const EdgeInsets.all(8.0),
@@ -305,14 +305,15 @@
   /// a list of [NavigationDestination]s.
   static Builder standardBottomNavigationBar({
     required List<NavigationDestination> destinations,
-    int currentIndex = 0,
+    int? currentIndex,
     double iconSize = 24,
     ValueChanged<int>? onDestinationSelected,
   }) {
+    currentIndex ??= 0;
     return Builder(
       builder: (_) {
         return BottomNavigationBar(
-          currentIndex: currentIndex,
+          currentIndex: currentIndex ?? 0,
           iconSize: iconSize,
           items: destinations
               .map((NavigationDestination e) => _toBottomNavItem(e))
diff --git a/packages/flutter_adaptive_scaffold/pubspec.yaml b/packages/flutter_adaptive_scaffold/pubspec.yaml
index 33b0353..e3fcb67 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
 
diff --git a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart
index 36a451c..7e3e46b 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 @@
       });
     },
   );
+
+  /// 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
diff --git a/packages/flutter_adaptive_scaffold/test/simulated_layout.dart b/packages/flutter_adaptive_scaffold/test/simulated_layout.dart
index e81a5ff..ae68715 100644
--- a/packages/flutter_adaptive_scaffold/test/simulated_layout.dart
+++ b/packages/flutter_adaptive_scaffold/test/simulated_layout.dart
@@ -36,7 +36,7 @@
     this.isAnimated = true,
   });
 
-  final int initialIndex;
+  final int? initialIndex;
   final bool isAnimated;
 
   static const List<NavigationDestination> destinations =
@@ -63,7 +63,7 @@
 }
 
 class TestScaffoldState extends State<TestScaffold> {
-  late int index = widget.initialIndex;
+  late int? index = widget.initialIndex;
 
   @override
   Widget build(BuildContext context) {
@@ -110,7 +110,7 @@
   Size get size => Size(_width, _height);
 
   MaterialApp app({
-    int initialIndex = 0,
+    int? initialIndex,
     bool animations = true,
   }) {
     return MaterialApp(