Flutter 如何在颤振中实现这一结果?
在“颤振”中选择选项卡时,如何使槽口显示? 以及如何通过在选择另一个选项卡时滑动凹口来设置更改的动画Flutter 如何在颤振中实现这一结果?,flutter,flutter-layout,flutter-animation,Flutter,Flutter Layout,Flutter Animation,在“颤振”中选择选项卡时,如何使槽口显示? 以及如何通过在选择另一个选项卡时滑动凹口来设置更改的动画 提前感谢您的帮助这是我可以做的解决方法: 进口“包装:颤振/材料.省道” void main() => runApp(MyApp()); /// This Widget is the main application widget. class MyApp extends StatelessWidget { static const String _title = 'Flutter
提前感谢您的帮助这是我可以做的解决方法: 进口“包装:颤振/材料.省道”
void main() => runApp(MyApp());
/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: <Widget>[
NavigationRail(
selectedIndex: _selectedIndex,
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
labelType: NavigationRailLabelType.selected,
destinations: [
NavigationRailDestination(
icon: Text("Food"),
label: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
)),
),
NavigationRailDestination(
icon: Text("Bakery"),
label: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
)),
),
NavigationRailDestination(
icon: Text("Drinks"),
label: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
)),
),
],
),
VerticalDivider(thickness: 1, width: 1),
// This is the main content.
Expanded(
child: Center(
child: Text(
'selectedIndex: $_selectedIndex',
style: Theme.of(context).textTheme.headline4,
),
),
)
],
),
);
}
}
void main()=>runApp(MyApp());
///此小部件是主应用程序小部件。
类MyApp扩展了无状态小部件{
静态常量字符串_title='颤振代码示例';
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:_标题,
主页:MyStatefulWidget(),
);
}
}
类MyStatefulWidget扩展了StatefulWidget{
MyStatefulWidget({Key}):超级(Key:Key);
@凌驾
_MyStatefulWidgetState createState()=>\u MyStatefulWidgetState();
}
类_MyStatefulWidgetState扩展状态{
int _selectedIndex=0;
@凌驾
小部件构建(构建上下文){
返回脚手架(
正文:世界其他地区(
儿童:[
导航轨道(
selectedIndex:\u selectedIndex,
onDestinationSelected:(int索引){
设置状态(){
_selectedIndex=索引;
});
},
labelType:NavigationRailLabelType.selected,
目的地:[
导航铁路目的地(
图标:文本(“食物”),
标签:集装箱(
宽度:8,
身高:8,
装饰:盒子装饰(
颜色:颜色,红色,
形状:BoxShape.circle,
)),
),
导航铁路目的地(
图标:文本(“面包店”),
标签:集装箱(
宽度:8,
身高:8,
装饰:盒子装饰(
颜色:颜色,红色,
形状:BoxShape.circle,
)),
),
导航铁路目的地(
图标:文本(“饮料”),
标签:集装箱(
宽度:8,
身高:8,
装饰:盒子装饰(
颜色:颜色,红色,
形状:BoxShape.circle,
)),
),
],
),
垂直分隔带(厚度:1,宽度:1),
//这是主要内容。
扩大(
儿童:中心(
子:文本(
'selectedIndex:$\u selectedIndex',
风格:Theme.of(context).textTheme.headline4,
),
),
)
],
),
);
}
}
您可以对侧栏使用
NavigationRail
。但我不知道如何制作凹口,无论如何我希望这能帮你一点忙这并不是你想要的,但它可能会给你一个如何制作的想法。这是你需要的凸面底部工具栏并不真正起作用,因为它主要用于底部导航栏,这是侧边栏我想youtube上有一个制作这样一个侧边栏的教程。