Flutter Check If Platform Is Ios Or Andriod

[Solved] Flutter Check If Platform Is Ios Or Andriod | Swift - Code Explorer | yomemimo.com
Question : flutter check if platform is ios or andriod

Answered by : chuks-okwuenu

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");
}

Source : | Last Update : Sat, 12 Mar 22

Answers related to flutter check if platform is ios or andriod

Code Explorer Popular Question For Swift