-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: flutter_adaptive_scaffoldThe flutter_adaptive_scaffold packageThe flutter_adaptive_scaffold packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
Description
Use case
In tablet or higher screen size devices, the package will show the NavigationRail instead of BottomNavigationBar. Thus it should consider its theme as well which is not working as of now.
- Main & Theme declared as below.
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.light().copyWith(
navigationRailTheme: const NavigationRailThemeData(
selectedIconTheme: IconThemeData(
size: 36.0,
color: Colors.red,
),
selectedLabelTextStyle: TextStyle(
fontSize: 20,
color: Colors.black,
),
unselectedLabelTextStyle: TextStyle(
fontSize: 16,
color: Colors.black,
),
),
),
home: const MyHomePage(),
);
}
}
- As we can see in my Material app theme, I have declared selected icon to be shown as in different colour (here, red), However, it is not working as expected.
- Attaching usage of
AdaptiveScaffoldas below:
class MyHomePage extends StatefulWidget {
/// Creates a const [MyHomePage].
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _selectedTab = 0;
@override
Widget build(BuildContext context) {
// Define the children to display within the body at different breakpoints.
final List<Widget> children = <Widget>[
for (int i = 0; i < 10; i++)
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
color: Colors.grey,
height: 400,
),
)
];
return AdaptiveScaffold(
useDrawer: false,
selectedIndex: _selectedTab,
onSelectedIndexChange: (int index) {
setState(() => _selectedTab = index);
},
destinations: const <NavigationDestination>[
NavigationDestination(
icon: Icon(Icons.inbox_outlined),
label: 'Inbox',
),
NavigationDestination(
icon: Icon(Icons.article_outlined),
label: 'Articles',
),
NavigationDestination(
icon: Icon(Icons.chat_outlined),
label: 'Chat',
),
NavigationDestination(
icon: Icon(Icons.video_call_outlined),
label: 'Video',
),
],
body: (_) => GridView.count(crossAxisCount: 2, children: children),
smallBody: (_) => ListView.builder(
itemCount: children.length,
itemBuilder: (_, int idx) => children[idx],
),
// Define a default secondaryBody.
secondaryBody: (_) => Container(
color: Colors.pink[200],
),
// Override the default secondaryBody during the smallBreakpoint to be
// empty. Must use AdaptiveScaffold.emptyBuilder to ensure it is properly
// overridden.
smallSecondaryBody: AdaptiveScaffold.emptyBuilder,
);
}
}
flutter doctor -vcommand executing as expected without any errors.- Output in simulator - Tablet in as screenshot attached below.
Proposal
If NavigationRailTheme is provided in material theme, it shall consider that if user has not given the theme related data explicitly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: flutter_adaptive_scaffoldThe flutter_adaptive_scaffold packageThe flutter_adaptive_scaffold packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
