Home > front end >  How do you detect the host platform from flutter dart?
How do you detect the host platform from flutter dart?

Time:03-07

For UI that should differ slightly on iOS and Android, ?

CodePudding user response:

import 'dart:io' show Platform;

Now you can detect the platform by just doing

Platform.isIOS // for ios
Platform.isAndroid //for android

CodePudding user response:

import 'dart:io' show Platform;

Now, you need to check whether you are on Web or Application.

if(kIsWeb) {
   Enter Web specific code here
} else {
   if(Platform.isIOS){
      Enter IOS specific code here.
   } else if (Platform.isAndroid){
      Enter Android specific code here.
   }
}

Platform has following options:

Platform.isAndroid
Platform.isFuchsia
Platform.isIOS
Platform.isLinux
Platform.isMacOS
Platform.isWindows
  • Related