Want to detect the host platform from Dart code? Use the below example code to detect the host platform from Dart code.
1 2 3 4 5 6 7 8 9 10 | import 'package:flutter/foundation.dart' show TargetPlatform; //... if(Theme.of(context).platform == TargetPlatform.android) //do sth for Android else if(Theme.of(context).platform == TargetPlatform.iOS) //do sth else for iOS else if(Theme.of(context).platform == TargetPlatform.fuchsia) //even do sth else for Fuchsia OS |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.