[flutter_adaptive_scaffold] : Add groupAlignment parameter to standardNavigationRail (#3673)
[flutter_adaptive_scaffold] : Add groupAlignment parameter to standardNavigationRail
diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md
index 32d90c0..793682b 100644
--- a/packages/flutter_adaptive_scaffold/CHANGELOG.md
+++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.1.3
+
+* Fixes `groupAlignment` property not available in `standardNavigationRail` - [flutter/flutter#121994](https://github.com/flutter/flutter/issues/121994)
+
## 0.1.2
* Fixes `NavigationRail` items not considering `NavigationRailTheme` values - [flutter/flutter#121135](https://github.com/flutter/flutter/issues/121135)
diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
index b74c0a4..3eb9ee6 100644
--- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
+++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart
@@ -260,6 +260,7 @@
Widget? leading,
Widget? trailing,
Function(int)? onDestinationSelected,
+ double? groupAlignment,
IconThemeData? selectedIconTheme,
IconThemeData? unselectedIconTheme,
TextStyle? selectedLabelTextStyle,
@@ -286,6 +287,7 @@
leading: leading,
trailing: trailing,
onDestinationSelected: onDestinationSelected,
+ groupAlignment: groupAlignment,
backgroundColor: backgroundColor,
extended: extended,
selectedIndex: selectedIndex,
diff --git a/packages/flutter_adaptive_scaffold/pubspec.yaml b/packages/flutter_adaptive_scaffold/pubspec.yaml
index 628211f..8157ffb 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.1.2
+version: 0.1.3
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 3b13d1c..6503538 100644
--- a/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart
+++ b/packages/flutter_adaptive_scaffold/test/adaptive_scaffold_test.dart
@@ -499,6 +499,50 @@
);
},
);
+
+ // This test checks whether AdaptiveScaffold.standardNavigationRail function
+ // creates a NavigationRail widget as expected with groupAlignment provided,
+ // and checks whether the NavigationRail's groupAlignment matches the expected value.
+ testWidgets(
+ 'groupAligment parameter of AdaptiveScaffold.standardNavigationRail works correctly',
+ (WidgetTester tester) async {
+ const List<NavigationRailDestination> destinations =
+ <NavigationRailDestination>[
+ NavigationRailDestination(
+ icon: Icon(Icons.home),
+ label: Text('Home'),
+ ),
+ NavigationRailDestination(
+ icon: Icon(Icons.account_circle),
+ label: Text('Profile'),
+ ),
+ NavigationRailDestination(
+ icon: Icon(Icons.settings),
+ label: Text('Settings'),
+ ),
+ ];
+
+ // Align to bottom.
+ const double groupAlignment = 1.0;
+
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Builder(
+ builder: (BuildContext context) {
+ return AdaptiveScaffold.standardNavigationRail(
+ destinations: destinations,
+ groupAlignment: groupAlignment,
+ );
+ },
+ ),
+ ),
+ ),
+ );
+ final NavigationRail rail =
+ tester.widget<NavigationRail>(find.byType(NavigationRail));
+ expect(rail.groupAlignment, equals(groupAlignment));
+ });
}
/// An empty widget that implements [PreferredSizeWidget] to ensure that