import 'package:flutter/foundation.dart' show kIsWeb;
if (kIsWeb) {
// running on the web!
} else {
// NOT running on the web! You can check for additional platforms here.
}
_checkingHostPlatform(){
if(IO.Platform.isAndroid){
//Execute code for android
}else if(IO.Platform.isIOS){
//Execute code for iOS
}else{
//Execute code for other platforms
}
}
import 'dart:io' show Platform;
if (Platform.isAndroid) {
// Android-specific code
} else if (Platform.isIOS) {
// iOS-specific code
}else if (Platform.isFuchsia) {
// Fuchsia-specific code
}else if (Platform.isLinux) {
// Linux-specific code
}else if (Platform.isMacOS) {
// MacOS-specific code
}else if (Platform.isWindows) {
// Windows-specific code
}else if (Platform.isWindows) {
// Windows-specific code
}
网络
import 'package:flutter/foundation.dart' show kIsWeb;
if (kIsWeb) {
// running on the web!
} else {
// NOT running on the web! You can check for additional platforms here.
}
import 'package:flutter/foundation.dart';
if (!kIsWeb && defaultTargetPlatform.isDesktop) {
// do stuff for desktop apps only
}
if (!kIsWeb && defaultTargetPlatform.isMobile) {
// do stuff for mobile apps only
}