CupertinoPicker-Example-iOS styling Flutter

CupertinoPicker widget is an iOS styled picker.

Displays its children widgets on a wheel for selection and calls back when the currently selected item changes.

Find below function to create a CupertinoPicker

 void _showPicker(BuildContext ctx) {
    showCupertinoModalPopup(
        context: ctx,
        builder: (_) => Container(
              height: 250,
              child: CupertinoPicker(
                backgroundColor: Colors.white,
                itemExtent: 30,
                scrollController: FixedExtentScrollController(initialItem: 1),
                children: [for (var i = 0; i < 10; i++) Text("Option $i")],
                onSelectedItemChanged: (value) {
                  setState(() {
                    print(value);
                  });
                },
              ),
            ));
  }

Complete main.dart file

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomeStateCupertinoPicker createState() => _MyHomeStateCupertinoPicker();
}
class _MyHomeStateCupertinoPicker extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: ElevatedButton(
          child: Text("Show Picker"),
          onPressed: () {
            _showPicker(context);
          },
        ),
      ),
    );
  }

  void _showPicker(BuildContext ctx) {
    showCupertinoModalPopup(
        context: ctx,
        builder: (_) => Container(
              height: 250,
              child: CupertinoPicker(
                backgroundColor: Colors.white,
                itemExtent: 30,
                scrollController: FixedExtentScrollController(initialItem: 1),
                children: [for (var i = 0; i < 10; i++) Text("Option $i")],
                onSelectedItemChanged: (value) {
                  setState(() {
                    print(value);
                  });
                },
              ),
            ));
  }
}

Result

Thanks for reading !!