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.

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 {
 @override
 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),
       ),
     ),
   );
 }
}

Questions?

Ask questions via GitHub below OR chat on Slack #questions