mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
918 B
37 lines
918 B
import 'package:flutter/cupertino.dart';
|
|
|
|
class SegmentedControlPage extends StatefulWidget {
|
|
const SegmentedControlPage({super.key});
|
|
|
|
@override
|
|
State<SegmentedControlPage> createState() => _SegmentedControlPageState();
|
|
}
|
|
|
|
class _SegmentedControlPageState extends State<SegmentedControlPage> {
|
|
int _selectedIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CupertinoPageScaffold(
|
|
navigationBar: const CupertinoNavigationBar(
|
|
middle: Text('Segmented Control'),
|
|
),
|
|
child: Center(
|
|
child: CupertinoSegmentedControl<int>(
|
|
children: <int, Widget>{
|
|
0: Text('One'),
|
|
1: Text('Two'),
|
|
2: Text('Three'),
|
|
},
|
|
onValueChanged: (int val) {
|
|
setState(() {
|
|
_selectedIndex = val;
|
|
});
|
|
},
|
|
groupValue: _selectedIndex,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|