mirror of
https://github.com/flutter/packages.git
synced 2025-06-29 06:06:59 +08:00
[flutter_adaptive_scaffold] Fix leading and trailing Navigation Rail Widgets (#3080)
The leading and trailing Navigation Rail widgets were not being passed through to the Navigation Rail. Fixes flutter/flutter#114684
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
## 0.0.9
|
||||||
|
|
||||||
|
* Fix passthrough of `leadingExtendedNavRail`, `leadingUnextendedNavRail` and `trailingNavRail`
|
||||||
|
|
||||||
## 0.0.8
|
## 0.0.8
|
||||||
|
|
||||||
Make fuchsia a mobile platform.
|
Make fuchsia a mobile platform.
|
||||||
|
@ -480,6 +480,8 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
|
|||||||
? Drawer(
|
? Drawer(
|
||||||
child: NavigationRail(
|
child: NavigationRail(
|
||||||
extended: true,
|
extended: true,
|
||||||
|
leading: widget.leadingExtendedNavRail,
|
||||||
|
trailing: widget.trailingNavRail,
|
||||||
selectedIndex: widget.selectedIndex,
|
selectedIndex: widget.selectedIndex,
|
||||||
destinations: widget.destinations
|
destinations: widget.destinations
|
||||||
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
||||||
@ -498,6 +500,8 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
|
|||||||
key: const Key('primaryNavigation'),
|
key: const Key('primaryNavigation'),
|
||||||
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
||||||
width: widget.navigationRailWidth,
|
width: widget.navigationRailWidth,
|
||||||
|
leading: widget.leadingUnextendedNavRail,
|
||||||
|
trailing: widget.trailingNavRail,
|
||||||
selectedIndex: widget.selectedIndex,
|
selectedIndex: widget.selectedIndex,
|
||||||
destinations: widget.destinations
|
destinations: widget.destinations
|
||||||
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
||||||
@ -510,6 +514,8 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
|
|||||||
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
||||||
width: widget.extendedNavigationRailWidth,
|
width: widget.extendedNavigationRailWidth,
|
||||||
extended: true,
|
extended: true,
|
||||||
|
leading: widget.leadingExtendedNavRail,
|
||||||
|
trailing: widget.trailingNavRail,
|
||||||
selectedIndex: widget.selectedIndex,
|
selectedIndex: widget.selectedIndex,
|
||||||
destinations: widget.destinations
|
destinations: widget.destinations
|
||||||
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
.map((_) => AdaptiveScaffold.toRailDestination(_))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: flutter_adaptive_scaffold
|
name: flutter_adaptive_scaffold
|
||||||
description: Widgets to easily build adaptive layouts, including navigation elements.
|
description: Widgets to easily build adaptive layouts, including navigation elements.
|
||||||
version: 0.0.8
|
version: 0.0.9
|
||||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_adaptive_scaffold%22
|
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
|
repository: https://github.com/flutter/packages/tree/main/packages/flutter_adaptive_scaffold
|
||||||
|
|
||||||
|
@ -193,6 +193,35 @@ void main() {
|
|||||||
expect(find.byType(PreferredSizeWidgetImpl), findsOneWidget);
|
expect(find.byType(PreferredSizeWidgetImpl), findsOneWidget);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Verify that the leading navigation rail widget is displayed
|
||||||
|
// based on the screen size
|
||||||
|
testWidgets(
|
||||||
|
'adaptive scaffold displays leading widget in navigation rail',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
await Future.forEach(SimulatedLayout.values,
|
||||||
|
(SimulatedLayout region) async {
|
||||||
|
final MaterialApp app = region.app();
|
||||||
|
await tester.binding.setSurfaceSize(region.size);
|
||||||
|
await tester.pumpWidget(app);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
if (region.size == SimulatedLayout.large.size) {
|
||||||
|
expect(find.text('leading_extended'), findsOneWidget);
|
||||||
|
expect(find.text('leading_unextended'), findsNothing);
|
||||||
|
expect(find.text('trailing'), findsOneWidget);
|
||||||
|
} else if (region.size == SimulatedLayout.medium.size) {
|
||||||
|
expect(find.text('leading_extended'), findsNothing);
|
||||||
|
expect(find.text('leading_unextended'), findsOneWidget);
|
||||||
|
expect(find.text('trailing'), findsOneWidget);
|
||||||
|
} else if (region.size == SimulatedLayout.small.size) {
|
||||||
|
expect(find.text('leading_extended'), findsNothing);
|
||||||
|
expect(find.text('leading_unextended'), findsNothing);
|
||||||
|
expect(find.text('trailing'), findsNothing);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An empty widget that implements [PreferredSizeWidget] to ensure that
|
/// An empty widget that implements [PreferredSizeWidget] to ensure that
|
||||||
|
@ -86,6 +86,9 @@ class TestScaffoldState extends State<TestScaffold> {
|
|||||||
smallSecondaryBody: (_) => Container(color: Colors.red),
|
smallSecondaryBody: (_) => Container(color: Colors.red),
|
||||||
secondaryBody: (_) => Container(color: Colors.green),
|
secondaryBody: (_) => Container(color: Colors.green),
|
||||||
largeSecondaryBody: (_) => Container(color: Colors.blue),
|
largeSecondaryBody: (_) => Container(color: Colors.blue),
|
||||||
|
leadingExtendedNavRail: const Text('leading_extended'),
|
||||||
|
leadingUnextendedNavRail: const Text('leading_unextended'),
|
||||||
|
trailingNavRail: const Text('trailing'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user