monadicstack/frodo

Support for flutter web

Opened this issue · 2 comments

I am using the frodo Dart/Flutter generator. I have a flutter app working on native platforms, but I'm getting this error when using flutter web: Unsupported operation: Platform._version. After a little investigation it appears this is occurring because the native Dart HttpClient is not support on web. There are third party packages, such as dio, which work for web. Are you considering supporting Flutter for web?

Thanks for uncovering that. Yeah, when I added flutter support, version 2.0 was a few weeks old so I hadn't poked around with it yet. I didn't realize that they wouldn't support the default HTTP client in web builds.

For the clients on non-Go languages, I'm trying to stick as close to the standard library as possible so that you're not forced to include extra dependencies just to talk to your backend services. In this case, however, it seems like it might be a necessity in the Flutter 2.0 world. All that to say, I like the idea of making sure that the flutter clients work on web build. I just have 2 thoughts about how to do it:

  • Which HTTP library should I used in the client? You suggested Dio which seems to be the most popular 3rd party option, but there's also the http package which is actually maintained by the Dart team, so fits more with the "stay closer to the standard library" approach I've tried to take. It sounds like Dio absolutely works in the web world, but I don't know if http does.
  • I'd probably just modify the existing client template for dart/flutter to use http/Dio rather than making a new template. While it does mean that rebuilding your Flutter client could break existing apps that don't import that package, I think the number of affected people would be low since this library's not that popular. But I think it would be worth it to ensure that the one and only "build a flutter client" command works for mobile and web versions of flutter.

Hi Rob,

I agree, staying with the standard library is best. I needed to get something working so I created a private fork and modified the template to use the http package. I have it working acceptably using http without the Authorization headers. I had to put a try/catch around the http.post, but didn't log why it was necessary.

I'm glad you are looking into this because I'm not sure how to modify the template to support all the features frodo provides. I created a fork at https://github.com/joebologna/frodo-flutter so I can continue working with it. The changes are on the flutter-web branch.

I agree with just changing the template. Flutter web is new, so anyone affected will likely be doing active development.

I'm actively building the Flutter app for the next few months, so I can test any changes you make or I can look into things you need help with.

Additionally, I did find a problem with the JavaScript template which I had to patch for the ReactJS version of the app. I could enter an issue about the problem and fix if you wish.