Retrieve the Platform on Which Our Flutter APP Runs: Web, iOS, Windows, Linux

Tiempo de lectura: < 1 minuto

Reading time: < 1 minute

Hello, today we are going to check the platform on which we run our Flutter app.

To detect if it is Android/iOS/Linux/Windows:

We import:

import 'dart:io' show Platform;

And we can use this if statement to verify the platform:

if (Platform.isIOS) {

} else if (Platform.isAndroid) {

}else if (Platform.isFuchsia) {

}else if (Platform.isLinux) {

}else if (Platform.isMacOS){

}else if (Platform.isWindows){

}

And to know if it is running on Mobile/Web:

We import:

import 'package:flutter/foundation.dart' show kIsWeb;

And we use this if statement:

if (kIsWeb) {

} else {

}

Leave a Comment