Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter check if platform is ios or andriod

create a file called target.dart and add this

import 'dart:io';
import 'package:flutter/foundation.dart' show kIsWeb;

extension Target on Object {
  bool isAndroid() {
    return Platform.isAndroid;
  } 
  bool isIOS() {
    return Platform.isIOS;
  } 
  bool isLinux() {
  return Platform.isLinux;
  } 
  bool isWindows() {
  return Platform.isWindows; 
  }
  bool isMacOS() {
  return Platform.isMacOS; 
  }
  bool isWeb() {
  return kIsWeb; 
  }
  // ···
}


then you can do something like this


if(isAndroid()){
	Text("Android");
}else{
	Text("Not Android");
}
Comment

PREVIOUS NEXT
Code Example
Dart :: six_ft_apart 
Dart :: dart every 
Dart :: flutter three line list 
Dart :: flutter listtile 
Dart :: string to datetime flutter 
Dart :: text wrap in flutter 
Dart :: dart read file 
Dart :: add border color to one side and rounded border container flutter 
Dart :: flutter main.dart 
Dart :: flutter status bar color 
Dart :: flutter rename 
Dart :: Shadow box around a button Flutter 
Dart :: dart variable in string 
Dart :: flutter length of string 
Dart :: dart switch case 
Dart :: Bad state: Stream has already been listened to 
Dart :: filterchip flutter 
Dart :: dart for in loop 
Dart :: fix portrait oreintation flutter 
Dart :: dart round 
Dart :: textbutton flutter 
Dart :: srring reverse dart 
Dart :: flutter asign class to map 
Dart :: using flutter google places 
Dart :: flutter counter app with block library 
Dart :: flutter check if null 
Dart :: flutter firebase 
Dart :: dart fold list 
Dart :: with keyword in dart 
Dart :: flutter multi icon button 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =