Skip to content

Instantly share code, notes, and snippets.

@loic-sharma
Last active March 11, 2025 18:33
Show Gist options
  • Save loic-sharma/ffc756351255114fa5468e968ee38c2f to your computer and use it in GitHub Desktop.
Save loic-sharma/ffc756351255114fa5468e968ee38c2f to your computer and use it in GitHub Desktop.
Cupertino Segmented controls
import 'package:flutter/cupertino.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: 'Cupertino segmented control demo',
home: CupertinoPageScaffold(
child: Center(
child: Column(
spacing: 10,
children: [
CupertinoSegmentedControl(
onValueChanged: (value) {},
children: {
0: Text('Foo'),
1: Text('Bar'),
},
),
CupertinoSlidingSegmentedControl(
onValueChanged: (value) {},
children: {
0: Text('Foo'),
1: Text('Bar'),
},
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment