- Introduction
- Basics
- App1 : Elon Musk’s Resume
- App2 : 5K Quotes
- App3 : Calculator
- App4_v1 : Flags Quiz
- Running Apps On Different Devices
- Debbuging
- App5 : Yacht Charter
- App6_v1 : My Books
- Creating responsive and adaptive apps
- App6_v2: My Books
- App7 : Short Vacation
- App8 : Movie Time
- App9 : Schedule Planner
- Shared Preferences
- App10 : Local Weather
- App11 : Discover Tunisia
Checking Device Platform
Messages are passed between the client (UI) and host (platform) using platform channels as illustrated in this diagram:
Messages and responses are passed asynchronously, to ensure the user interface remains responsive.
Detecting the Current Platform – iOS or Android
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'responsive and adaptive',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
var platform = Theme.of(context).platform;
return Scaffold(
appBar: AppBar(
title:
Text(platform == TargetPlatform.iOS ? 'iOS' : 'Android or Other'),
),
);
}
}