Open AbhishekDoshi26 opened 1 year ago
/cc @lrhn @mit-mit
See https://github.com/dart-lang/io/issues/93#issuecomment-1371372964 for some issues with the claims here.
(Filing three copies of the same issue in different repositories makes discussion really difficult; please just pick one location in the future.)
Ping @mit-mit @lrhn. Do we have an issue somewhere which reflects our plans for platform detection improvements? I would like to either label this issue or close it in favor of existing issue.
We all know that using
Platform.isAndroid
andPlatform.isIOS
crashes on web because these constants lie insidedart:io
which is not supported for web and many times no one really checks which file was imported due to the usage of something.But, many less experienced developers keep on using these for multi-platform apps because they are habitual to use it. We already have an alternative i.e. to lay down the if-else such that it checks for web first. Or, we can also use
defaultTargetPlatform == TargetPlatform.android
as this works on all platforms.I propose either of the following:
This will really help developers to not make silly mistakes of using
Platform.is*
in multi-platform projects.Note: Opened similar issue in dart-lang repo too.