Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_adaptive_scaffold] allow users to override navigation rail padding from AdaptiveScaffold constructor #8433

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/flutter_adaptive_scaffold/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 0.3.1

* Add `navigationRailPadding` padding to `AdaptiveScaffold` to allow for specifying custom padding around the navigation rail.

## 0.3.1

* Use improved MediaQuery methods.

## 0.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class AdaptiveScaffold extends StatefulWidget {
this.leadingUnextendedNavRail,
this.leadingExtendedNavRail,
this.trailingNavRail,
this.navigationRailPadding,
this.smallBody,
this.body,
this.mediumLargeBody,
Expand Down Expand Up @@ -148,6 +149,9 @@ class AdaptiveScaffold extends StatefulWidget {
/// navigation rail at the largest breakpoint.
final Widget? trailingNavRail;

/// Option to apply custom padding to the navigation rail.
final EdgeInsetsGeometry? navigationRailPadding;

/// The alignment of the destinations in the navigation rail.
final double? groupAlignment;

Expand Down Expand Up @@ -343,7 +347,7 @@ class AdaptiveScaffold extends StatefulWidget {
int? selectedIndex,
bool extended = false,
Color? backgroundColor,
EdgeInsetsGeometry padding = const EdgeInsets.all(8.0),
EdgeInsetsGeometry? padding,
Widget? leading,
Widget? trailing,
void Function(int)? onDestinationSelected,
Expand All @@ -359,7 +363,7 @@ class AdaptiveScaffold extends StatefulWidget {
}
return Builder(builder: (BuildContext context) {
return Padding(
padding: padding,
padding: padding ?? const EdgeInsets.all(8.0),
child: SizedBox(
width: width,
height: MediaQuery.sizeOf(context).height,
Expand Down Expand Up @@ -608,6 +612,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
width: widget.navigationRailWidth,
leading: widget.leadingUnextendedNavRail,
trailing: widget.trailingNavRail,
padding: widget.navigationRailPadding,
selectedIndex: widget.selectedIndex,
destinations: destinations,
onDestinationSelected: widget.onSelectedIndexChange,
Expand All @@ -627,6 +632,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
extended: true,
leading: widget.leadingExtendedNavRail,
trailing: widget.trailingNavRail,
padding: widget.navigationRailPadding,
selectedIndex: widget.selectedIndex,
destinations: destinations,
onDestinationSelected: widget.onSelectedIndexChange,
Expand All @@ -646,6 +652,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
extended: true,
leading: widget.leadingExtendedNavRail,
trailing: widget.trailingNavRail,
padding: widget.navigationRailPadding,
selectedIndex: widget.selectedIndex,
destinations: widget.destinations
.map((NavigationDestination destination) =>
Expand All @@ -666,6 +673,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
extended: true,
leading: widget.leadingExtendedNavRail,
trailing: widget.trailingNavRail,
padding: widget.navigationRailPadding,
selectedIndex: widget.selectedIndex,
destinations: widget.destinations
.map((NavigationDestination destination) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_adaptive_scaffold/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_adaptive_scaffold
description: Widgets to easily build adaptive layouts, including navigation elements.
version: 0.3.1
version: 0.3.2
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,18 @@ void main() {
expect(rail.labelType, NavigationRailLabelType.all);
},
);

testWidgets('AdaptiveScaffold builds without throwing an error', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: AdaptiveScaffold(
destinations: const <NavigationDestination>[
NavigationDestination(icon: Icon(Icons.inbox), label: 'Inbox'),
NavigationDestination(icon: Icon(Icons.article), label: 'Articles'),
],
),
));
expect(tester.takeException(), isNull);
});
}

/// An empty widget that implements [PreferredSizeWidget] to ensure that
Expand Down
Loading