简体   繁体   中英

Create flutter library to support both web and mobile

I need to create a library which implements a data persistence which should work across mobile and web. For web, I need to import 'dart:html' and for mobile I would use shared preferences.

Problem is, the project won't compile for mobile if "dart:html" is imported. Does there exist a way around for this? Maybe I could have conditional imports?

Can load different handlers by judging (I support you writing this library)

import '_network_image_io.dart' if (dart.library.html) '_network_image_web.dart' as network_image;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM