1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-19 21:41:43 +00:00
Files
samples/cupertino_gallery/lib/widgets/switch_page.dart
2026-04-15 13:02:16 -07:00

30 lines
656 B
Dart

import 'package:flutter/cupertino.dart';
class SwitchPage extends StatefulWidget {
const SwitchPage({super.key});
@override
State<SwitchPage> createState() => _SwitchPageState();
}
class _SwitchPageState extends State<SwitchPage> {
bool _value = true;
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(middle: Text('Switch')),
child: Center(
child: CupertinoSwitch(
value: _value,
onChanged: (bool value) {
setState(() {
_value = value;
});
},
),
),
);
}
}