5

Is possible to use some widgets from flutter/cupertino.dart inside a material app? (Using the Scaffold)

I want to render the Switch widget with the cupertino style instead the material.

Pablo Cegarra
  • 20,955
  • 12
  • 92
  • 110
  • 1
    https://stackoverflow.com/questions/54976050/material-datepicker-with-cupertino-ui/54976599#54976599 – Mazin Ibrahim Mar 04 '19 at 15:52
  • Can you include some example of extending one Cupertino widget please? – Pablo Cegarra Mar 04 '19 at 15:55
  • This is an example from the medium post mentioned in the answer : @Override CupertinoNavigationBar createIosWidget(BuildContext context) => new CupertinoNavigationBar ( leading: leading, middle: title, ); – Mazin Ibrahim Mar 04 '19 at 16:01

1 Answers1

5

yes you can just import flutter/cupertino.dart and use it like this:

import 'package:flutter/cupertino.dart';
Scaffold(
  body:Column(

     children:<Widget>[
       CupertinoSwitch(
         value: value,
         onChanged: (val){
         setState(() {
            value = val;
         });
        },
     )


     ]
  )
)
Sami Kanafani
  • 14,244
  • 6
  • 45
  • 41