4

Show me your main.dart - Flutter research

 3 years ago
source link: https://dev.to/nombrekeff/show-me-what-you-got-in-your-main-dart-4l15
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Cover image for Show me your main.dart - Flutter research

Show me your main.dart - Flutter research

Aug 31

・1 min read

Do you work on a Flutter project? If so, please share your main.dart file with me (if you want and can).

I'm researching how people organize their main.dart files for a new post for my series Let's learn Flutter. I might want to include some of the entries in the post (and credit you of course).

So, if you're up to it, please share you main.dart file and a little overview on why you organized it that way.

Discussion (13)

pic

CollapseExpand

CollapseExpand

I will also add riverpod to my list of reactive options. Never heard of it, looks good!
Do you have experience with it?

Comment button Reply

CollapseExpand

Yes, I have been using Riverpod for quite some time now. Riverpod makes my life so much easier. Previously I used Provider for most of my projects but certain limitations made me switch and Riverpod was the No Brainer for me since its very similar to Provider and is superior . I would highly recommend you to give it a try if you're looking for a state management solution.

Thread

Thread

Author

Aug 31

Cool I will check it out for sure! I'm sticking with provider for now for most projects and have not found many limitations yet. Can I ask you which were the limitations you encountered? And what were the reasons you chose Riverpod over other solutions, like let's say, redux or mobx?

I'm also doing research on these topics, so it would be really interesting to hear about that too!

Thread

Thread

The first and far most important thing about Riverpod is that it helps in keeping the business logic and the Widgets separate making the Widget Tree clean and easier to read.
The second thing is that Provider is not compile-time safe.For instance, Provider will only prompt you with an error at runtime If you try to use a Provider that does not even exist.
Another one is the if there are multiple providers of same type within the widget tree, Using Provider, you can only listen to the one which is closer to the Consumer Widget. With Riverpod, you can consume any provider anytime and even anywhere since the Providers are globally defined.

And the list goes on.I hope it helped! If you need more help with it, let me know!

Thread

Thread

Author

Aug 31

Makes sense, thanks for the info. I might get in touch once I start researching more about it!

Thread

Thread

I'm here if you need help. Just let me know

Comment button Reply

CollapseExpand

Author

Aug 31

Thanks for the addition!

I found a really usefull package from this, did not know of the existance of device_preview, really usefull package!

Comment button Reply

CollapseExpand

CollapseExpand

Author

Aug 31

I'll start, this is one of mine:

import 'package:flutter/material.dart';
import 'package:pegues/api/local/loading.dart';
import 'package:pegues/app.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Loading.setup();

  runApp(const PeguesApp());
}
Enter fullscreen modeExit fullscreen mode

Comment button Reply

CollapseExpandCollapseExpand

CollapseExpand

Author

Aug 31

Thanks for the addition @cahyowhy . I like that you're handling errors, great stuff! did not know about catcher either (I'm discovering a load of cool packages from this post), we use Sentry at our company for this.

Comment button Reply


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK