0

In my flutter app i have imported the flutter file_picker library. However this library does not currently support flutter web. The library is not imperative to my apps use.

THE MAIN QUESTION: Is there any way to check whether a library imported is unsupported and then in which case I can remove parts of the UI and code?

Robert A
  • 31
  • 1
  • 3

3 Answers3

0

I don't think it is possible, but knowing the limitations of the library, you could simply add the logic yourself for not showing some widget, based on the host, like this.

joaortk
  • 73
  • 1
  • 9
0

To check whether a given library has web support is available, head to https://pub.dev/ , paste the package name in the search bar and check whether the result has a web label. If the library is not available for the web, you can search for an alternative and do some refactoring, but since Flutter 2 was released, the most popular libraries are supported.

Răzvan Puiu
  • 671
  • 1
  • 6
  • 24
0

You could check if the user is using a supported platform by excluding the ones which are not.

For example:

import 'dart:io'; //Required import

if (Platform.isAndroid || Platform.isIOS) {
    //Do some stuff with the file_picker library
} else {
    //Tell the user that his platform is not currently supported
}
Dani3le_
  • 1,257
  • 1
  • 13
  • 22