Platform Checking Material vs Cupertino Widgets

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.
Get Unlimited PRO Access


*Enrollment provides full access to this course (and updates) for life.

Example Code

file_type_dartlang main.dart
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'dart:io' show Platform;

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       body: Center(
         child: Platform.isAndroid
             ? Switch(value: true, onChanged: (v) => null)
             : CupertinoSwitch(value: true, onChanged: (v) => null),

Q&A Chat