Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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");
}
 
PREVIOUS NEXT
Tagged: #flutter #check #platform #ios #andriod
ADD COMMENT
Topic
Name
7+1 =