Unsupported operation: Platform._operatingSystem
You can use a try-catch
block to prevent the exception from breaking the flow:
bool kisweb;
try{
if(Platform.isAndroid||Platform.isIOS) {
kisweb=false;
} else {
kisweb=true;
}
} catch(e){
kisweb=true;
}
I reopen this issue to give a more appropriate answer which is now available in native in flutter:
import 'package:flutter/foundation.dart';
if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.android) {
// Some android/ios specific code
}
else if (defaultTargetPlatform == TargetPlatform.linux || defaultTargetPlatform == TargetPlatform.macOS || defaultTargetPlatform == TargetPlatform.windows) {
// Some desktop specific code there
}
else {
// Some web specific code there
}