gskinnerTeam / flutter-universal-platform

A web-safe implementation of dart.io.Platforms. Helps avoid the "Unsupported operation: Platform._operatingSystem" runtime error.
MIT License
105 stars 27 forks source link

Cannot run with sound null safety, because the following dependencies #25

Closed syeds-git closed 1 year ago

syeds-git commented 1 year ago

I get following error when I try to use the package:

Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

syeds-git commented 1 year ago

The only reason to use this package is to avoid the issue with calling Platform.iOS etc. I think the solution is already provided in the following file:

https://github.com/gskinnerTeam/flutter-folio/blob/master/lib/_utils/device_info.dart

The only change is to use the following:

  static bool isWeb = kIsWeb;

  // Syntax sugar, proxy the UniversalPlatform methods so our views can reference a single class
  static bool isIOS = !kIsWeb && Platform.isIOS;
  static bool isAndroid = !kIsWeb && Platform.isAndroid;
  static bool isMacOS = !kIsWeb && Platform.isMacOS;
  static bool isLinux = !kIsWeb && Platform.isLinux;
  static bool isWindows = !kIsWeb && Platform.isWindows;

After the above change, I see no other reason to use the flutter-universal-platform package. Let me know if I am missing something.