【发布时间】:2021-05-12 18:58:14
【问题描述】:
这个父底部导航栏
import 'package:flutter/material.dart';
class BottomNavigation extends StatefulWidget {
BottomNavigation({
Key? key,
}) : super(key: key);
@override
_BottomNavigationState createState() => _BottomNavigationState();
}
class _BottomNavigationState extends State<OARBottomNavigation> {
int _selectedIndex = 0;
List<Widget> _widgetOptions = [
Screen1(),
Screen2(),
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: SideDrawer(),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.assignment_turned_in),
label: 'Screen 1',
),
BottomNavigationBarItem(
icon: Icon(Icons.people),
label: 'Screen 2',
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
body: Scaffold(
body: _widgetOptions.elementAt(_selectedIndex),
),
);
}
}
现在在屏幕 1 上,我想打开 Drawer()。
import 'package:flutter/material.dart';
class Screen1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Screen 1 Title'),
),
body: Container(
child: Text('This is Screen 1'),
),
),
);
}
}
如何从屏幕 1 打开抽屉?
【问题讨论】:
-
抽屉:SideDrawer(),添加到脚手架下
-
如果我这样做,它会出现在底部导航的后面。我想出现在底部导航的顶部。
-
我之前查看了该链接,但没有看到我没有做的任何事情。
标签: flutter