答案 0 :(得分:15)
我发现最好的是CupertinoSlidingSegmentedControl()
:
class _ViewState extends State<View> {
int segmentedControlGroupValue = 0;
final Map<int, Widget> myTabs = const <int, Widget>{
0: Text("Item 1"),
1: Text("Item 2")
};
@override
Widget build(BuildContext context) {
return Scaffold(
body: CupertinoSlidingSegmentedControl(
groupValue: segmentedControlGroupValue,
children: myTabs,
onValueChanged: (i) {
setState(() {
segmentedControlGroupValue = i;
});
}),
);
}
}
希望这会有所帮助。请参阅文档here。
答案 1 :(得分:1)