Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate flutter mobile app to flutter web

I have a mobile app written with flutter and i would like to convert it into a flutter_web app (integrating flutter_web is not available yet). I'm currently having problems with packages.

I have followed the instructions listed in this website https://www.codemitter.com/how-to-add-web-counterpart-in-an-existing-flutter-project/

I get the following errors

webdev could not run for this project.
You have a dependency on `cached_network_image` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `cloud_firestore` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `cupertino_icons` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `firebase_core` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `flutter` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `path_provider` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `sqflite` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
pub finished with exit code 78

are the flutter_web versions for the following plugins? how would one manually/automatically change such a plugin to be supported on flutter_web?

like image 715
Meth Munindradasa Avatar asked Oct 18 '25 22:10

Meth Munindradasa


2 Answers

Steps to follow while migration to Flutter Web:

  1. update build config according to the migration guide

  2. replace all flutter imports with flutter_web

  3. remove all plugins that depend on native platforms (android or ios) and replace them with equivalents from dart:html or pure dart web libraries (https://pub.dev/web)

  4. use forked non-native libraries that depend on flutter framework, like this https://github.com/rrousselGit/provider/issues/82 you might need to create a fork yourself like this: https://github.com/kevmoo/provider/commit/bb739c96463347dd185331655e1d8895665172b9

Steps 1. and 2. are pice of cake. But 3. and 4. might be very paintful.

like image 101
Dariusz Bacinski Avatar answered Oct 21 '25 01:10

Dariusz Bacinski


Plugins are not yet supported on flutter_web and we don't yet have details on what the migration story will look like. Plugins which call through to native Java or Swift code will not be possible to migrate automatically. Any code which imports dart:io or dart:isolate is also unsupported and would need to be rewritten.

like image 26
Nate Bosch Avatar answered Oct 20 '25 23:10

Nate Bosch