-
Hi, Given that this package is web only, do you have any recommendation how to use this package in multi-platform flutter env? |
Beta Was this translation helpful? Give feedback.
Answered by
Zekfad
Feb 2, 2023
Replies: 1 comment
-
You can use // platfrom.dart
export 'platform/stub.dart'
if (dart.library.io) 'platform/io.dart'
if (dart.library.js) 'platform/js.dart'
if (dart.library.html) 'platform/js.dart'; // platform/stub.dart
/// Returns platform appropriate [Client].
Client getClient() {
throw UnsupportedError('Stub code is called');
} // platform/js.dart
/// Returns platform appropriate [Client].
Client getClient() => FetchClient(/* ... */); // platform/io.dart
/// Returns platform appropriate [Client].
Client getClient() => IOClient(/* ... */); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Zekfad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
http
module on all platforms. Use conditional imports to import target client, e.g. like this: