1

This error got me confusing since I can't use the class Platform but I have already added its library dart.io (and even upgraded the pubspec file). The strange thing is that the class appears : enter image description here

but when Im using it, it throws an error enter image description here

any idea if it is a flutter bug?

Neil Milke
  • 11
  • 1
  • 3
    You are importing both the `'dart:html'` and `'dart:io' packages, both of which define a `Platform` class, and the analyzer doesn't know which one you are trying to reference. You need to label one of the imports such as `import 'dart:io' as io;` and then use the label to specify which one you want like `io.Platform.isAndroid`. (And on a separate note, you shouldn't import both of these packages as they are mutually exclusive. Only import one or the other depending on if this is for mobile/desktop development or for web development.) – Abion47 Jul 04 '21 at 07:42
  • Does [this](https://stackoverflow.com/questions/57951672/try-using-as-prefix-for-one-of-the-imported-directives-or-hiding-the-name-from) helps? – Tamir Abutbul Jul 04 '21 at 07:42
  • Change import path to `import 'dart:io' as io;` and use `io.Platform.isAndroid`. – Aayush Shah Jul 04 '21 at 07:44
  • exactly the problem. I would never think of this, thank you guys – Neil Milke Jul 04 '21 at 08:50

0 Answers0