-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#3080Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5Found to occur in 3.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: flutter_adaptive_scaffoldThe flutter_adaptive_scaffold packageThe flutter_adaptive_scaffold packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
- Execute
flutter runon the code sample - Resize window
Expected results:
On Extended Navigation Rail:
On Unextended Navigation Rail: (Since there is no trailingUnextendedNavRail property)
Actual results:
On Extended Navigation Rail:
On Unextended Navigation Rail:
Code sample
import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorSchemeSeed: const Color(0xFFE4935D),
useMaterial3: true,
brightness: Brightness.light,
),
// darkTheme: ThemeData(
// colorSchemeSeed: const Color(0xFFE4935D),
// useMaterial3: true,
// brightness: Brightness.dark,
// ),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return AdaptiveScaffold(
appBar: AppBar(
elevation: 4,
title: const Text('Demo App'),
),
useDrawer: false,
trailingNavRail: OutlinedButton.icon(
icon: const Icon(Icons.exit_to_app),
onPressed: () {},
label: const Text('Exit'),
),
leadingExtendedNavRail: OutlinedButton.icon(
icon: const Icon(Icons.add),
onPressed: () {},
label: const Text('New'),
),
leadingUnextendedNavRail: IconButton(
icon: const Icon(Icons.add),
onPressed: () {},
),
destinations: const <NavigationDestination>[
NavigationDestination(
icon: Icon(Icons.home),
label: 'Home',
),
NavigationDestination(
icon: Icon(Icons.add_box),
label: 'Counter',
),
],
body: (final _) {
return const SizedBox.shrink();
},
onSelectedIndexChange: (final index) {},
);
}
}This issue is caused because the leading and trailing widgets are not passed into AdaptiveScaffold.standardNavigationRail() function from AdaptiveScaffold widget in adaptive_scaffold.dart.
The solution:
After providing leading and trailing widgets to AdaptiveScaffold.standardNavigationRail() from AdaptiveScaffold widget, it works as expected.
class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
@override
Widget build(BuildContext context) {
return Directionality(
...
body: AdaptiveLayout(
bodyOrientation: widget.bodyOrientation,
bodyRatio: widget.bodyRatio,
internalAnimations: widget.internalAnimations,
primaryNavigation: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
widget.mediumBreakpoint: SlotLayout.from(
key: const Key('primaryNavigation'),
builder: (_) => AdaptiveScaffold.standardNavigationRail(
width: widget.navigationRailWidth,
selectedIndex: widget.selectedIndex,
leading: widget.leadingUnextendedNavRail, // add this line
destinations: widget.destinations
.map((_) => AdaptiveScaffold.toRailDestination(_))
.toList(),
onDestinationSelected: widget.onSelectedIndexChange,
),
),
widget.largeBreakpoint: SlotLayout.from(
key: const Key('primaryNavigation1'),
builder: (_) => AdaptiveScaffold.standardNavigationRail(
width: widget.extendedNavigationRailWidth,
extended: true,
leading: widget.leadingExtendedNavRail, // add this line
trailing: widget.trailingNavRail, // add this line
selectedIndex: widget.selectedIndex,
destinations: widget.destinations
.map((_) => AdaptiveScaffold.toRailDestination(_))
.toList(),
onDestinationSelected: widget.onSelectedIndexChange,
),
),
},
),
...
);
}
}Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5Found to occur in 3.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: flutter_adaptive_scaffoldThe flutter_adaptive_scaffold packageThe flutter_adaptive_scaffold packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version