How to import platform specific dependency in Flutter/Dart? (Combine Web with Android/iOS)
问题 I am using shared_preferences in my Flutter application for iOS and Android. On the web I am using the http:dart dependency ( window.localStorage ) itself. Since Flutter for web was merged into the Flutter repo, I want to create a cross platform solution. This means I need to import two seperate API's. This seems not to be very good supported in Dart yet, but this is what I did: import 'package:some_project/stub/preference_utils_stub.dart' if (dart.library.html) 'dart:html' if (dart.library