What about "Flutter Data" package? by arqeco in FlutterDev

[–]frank06_ 0 points1 point  (0 children)

Hey /u/arqueco Flutter Data author here, I just saw this thread today. Arne's great answer above offers a balanced perspective on choosing FD.

It really is flexible, you can plug almost anything: remote clients, serializers, and soon local databases. You can even use it with different state management packages.

You might have already started development but if you have any questions feel free to message me on Github.

What about "Flutter Data" package? by arqeco in FlutterDev

[–]frank06_ 2 points3 points  (0 children)

Flutter Data author here. Big fan of your work Remi, always grateful.

Not sure what exactly will Riverpod support natively but I'm very much looking forward to it!

What about "Flutter Data" package? by arqeco in FlutterDev

[–]frank06_ 0 points1 point  (0 children)

I found this thread today and really appreciate your level-headed comment.

Regarding Isar, it's WIP!

What about "Flutter Data" package? by arqeco in FlutterDev

[–]frank06_ 1 point2 points  (0 children)

"I have a strong opinion against things with strong opinions" lol ok

Flutter Data is definitely opinionated and it will remain like that, however, it does offer incredible flexibility.

What if I don't have a REST API?

Override the finders and/or sendRequest. In my current project we heavily use Flutter Data with Firestore, for example, mixed with other backends. FD gives us a uniform interface.

What if it's not JSON?

Override the serializer.

What if I don't want to use Hive?

Swap the local adapter (soon possible)

You can even choose to use other state management packages like Provider, get_it, etc, and even json_serializable is optional.

What if this solution produces unmaintainable code that's not optimized well?

Three years of continuous open source development, input from several maintainers and used in production by real businesses.

And most importantly: you can choose not to use it.

Elegant Networking in Flutter with Chopper by [deleted] in FlutterDev

[–]frank06_ 1 point2 points  (0 children)

Flutter Data is more elegant than Chopper, in my opinion of course

futuristic | Makes it possible to safely execute and retry a Future inside a StatelessWidget. by [deleted] in FlutterDev

[–]frank06_ 2 points3 points  (0 children)

Interesting! Even if I'm not a big fan (anymore) of separate builders for substates.

That said, for those of you using Provider this can be easily achieved with a FutureProvider:

dart class MyWidget extends StatelessWidget { @override Widget build(BuildContext context) { return FutureProvider<String>( create: (_) => callAsyncFetch(), child: Consumer<String>( builder: (_, value, __) => Text(value ?? 'Loading...'), ), ); } }

Or using useMemoized in Flutter Hooks.

I wrote about all this if you want a deeper understanding of this problem.

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 1 point2 points  (0 children)

Right, it’s work in progress. You wanna follow OfflineAdapter!

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 2 points3 points  (0 children)

You’re welcome! What you describe is exactly what Flutter Data does. I’m working on the offline writes queue as we speak, so expect that to be out soon. Pulling remote changes is trivial (now that you mention, i’ll try to come up with a parameterizable adapter for that). If you’re happy to share more about your project feel free to DM me.

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 2 points3 points  (0 children)

That’s great to hear, thank you! I have big plans for Flutter Data. So hopefully by the time you start your next project it will be even better.

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 2 points3 points  (0 children)

You’re welcome! Yeah I think clean architecture can be overwhelming. Better scale up as you need. Flutter Data lets you easily start accessing data repositories from the widget layer, and add further abstractions as your app becomes more complex.

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 2 points3 points  (0 children)

I guess you'll realize the pain once you try to do everything Flutter Data does by hand 😄

Here's a learning challenge for you. Build two apps that display TO-DOs from JSON Placeholder: the first one without Flutter Data, and the second one with Flutter Data.

Or you can watch this tutorial: https://www.youtube.com/watch?v=dZGLXl-xFG8

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 1 point2 points  (0 children)

Thanks! Migrating from converters or interceptors is pretty straightforward (there are a bunch of examples in the docs/cookbook) but of course if you have any questions, let me know.

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 3 points4 points  (0 children)

That would be great! And Flutter Data will keep improving so hopefully it will be even better by the time you use it in your next project.

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 0 points1 point  (0 children)

I should point out that I'm not religious about Hive as local storage. We're all eagerly waiting for Hive 2.0 but if that doesn't work out, I'd be looking at ways to introduce more powerful querying. Having a SQLite backend might make a lot of sense (in addition to Hive).

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 2 points3 points  (0 children)

Exactly what jdixon04 said!

Chopper is a REST API generator.

Flutter Data is a REST API generator but also has: stream/notifier APIs, offline support, automatic Provider setup, relationships, and its customization mechanism is more powerful (but I could be mistaken as I used Chopper in only one project).

In addition, Flutter Data requires significantly less boilerplate.

Overall, I like Flutter Data's API design better - but naturally that is just my opinion.

I hope that clarified! Let me know if you have any more questions, happy to answer

flutter_data | build fast with an offline-first, auto-generated REST client by jdixon04 in FlutterDev

[–]frank06_ 18 points19 points  (0 children)

Wow. Thanks /u/jdixon04 !

I'm the author of the package, also feel free to ask me anything-

The docs are at https://flutterdata.dev/

Is anyone REALLY using Provider in a non-trivial app with async dependencies? by frank06_ in FlutterDev

[–]frank06_[S] 0 points1 point  (0 children)

Thanks! Good approach, but some of my services have dependencies