如何在颤动中实现这个结果?
How to achieve this result in flutter?
如何在Flutter中选择标签时出现缺口?
以及如何通过在选择另一个选项卡时让槽口滑动来动画更改?
提前感谢您的帮助
这是我可以采取的解决方法:
导入 'package:flutter/material.dart';
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,
),
),
)
],
),
);
}
}
您可以将 NavigationRail
用于边栏。但是不知道怎么打,总之希望对大家有所帮助
如何在Flutter中选择标签时出现缺口? 以及如何通过在选择另一个选项卡时让槽口滑动来动画更改?
提前感谢您的帮助
这是我可以采取的解决方法: 导入 'package:flutter/material.dart';
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,
),
),
)
],
),
);
}
}
您可以将 NavigationRail
用于边栏。但是不知道怎么打,总之希望对大家有所帮助