[英]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.我需要创建一个实现数据持久性的库,该库应该可以跨移动设备和 web 工作。 For web, I need to
import 'dart:html'
and for mobile I would use shared preferences.对于 web,我需要
import 'dart:html'
,对于移动设备,我会使用共享首选项。
Problem is, the project won't compile for mobile if "dart:html" is imported.问题是,如果“dart:html”被导入,该项目将无法为移动设备编译。 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)可以通过判断来加载不同的handler(我支持你写这个库)
import '_network_image_io.dart' if (dart.library.html) '_network_image_web.dart' as network_image;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.