简体   繁体   English

创建 flutter 库以支持 web 和移动

[英]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.

相关问题 在 flutter 中使用谷歌地图移动和 web - Using Google Maps in flutter for both mobile and web 在 Flutter 网页和移动应用中使用 Firebase - Use Firebase in both Flutter web AND mobile app 我想创建支持 web、桌面和移动 ui 等所有平台的 flutter 架构 - I want to create flutter architecture that support all platforms like web ,desktop and mobile ui Flutter Web:创建具有移动应用大小的 UI - Flutter Web : Create UI with mobile app size 我如何同时处理 Web 和移动项目颤振 - How can I work on both a web and a mobile project flutter 将 flutter 用于移动和 web 用于社交媒体平台是否可行? - Is using flutter for both mobile and web for a social media platform feasible? 如何创建同时支持 flutter 和 dart 的 package - How to create a package with support for both flutter and dart at the same time 可以使用 web flutter 创建管理面板,并在移动 flutter 应用程序中使用它 - It is possible to create an administrative panel with web flutter and use it in a mobile flutter application 有AdMob支持Flutter web吗? - Is there AdMob support for Flutter web? 如何使用 Flutter 使用客户端移动应用程序创建管理员 Web 应用程序 - How to create an admin Web app with client Mobile app using Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM