DEV Community

rubensdemelo
rubensdemelo

Posted on • Updated on

How to not start with Flutter

How to not start with Flutter

Some days ago I posted on twitter my biggest mistake about learning Flutter:

(Now, provider package is the new recomendation by Flutter docs)

Motivated by a lot of questions on Stack Overflow about "BLoC" pattern,
I decided to share on Twitter (and surprisingly got some nice feedbacks) and now write this post to help future flutter developers.

Almost every single day, newcomers on flutter post questions about "BLoC" or even worst, about packages that makes "simple" to implement this pattern.

You have other topics that really matter in the beginning:

  • Dart language (even if it is not hard)
  • Widget tree
  • Box Constraints
  • Basic widgets
  • Stateless and Stateful widgets
  • Navigation
  • Widgets lifecycle
  • Material and Cupertino packages
  • Keys

When you need to share values between widget or pass them down in your widget tree, use InheritedWidget, it is easy and probably meet what you need in the first steps. If you already use MediaQuery.of(context) or Theme.of(context), you already used InheritedWidget.

And even after having good knowledge about topics above, when you started with state management, there are excellent packages to start: scoped_model and the most recent and powerful provider. I strongly recommended scoped_model. It is simple to understand, well documented, works fine for small and medium apps (no matter how complexity app is) and was explicitly the first package about state management recommended by Flutter docs (and now provider is the new black).

Keep in mind that state management isn't a simple topic, there isn't a better approach and Flutter let you chose whatever solution you want. And the most important on your journey is to discover what solution fits your needs and what solution you feel more comfortable and confident to use in your app.

In conclusion, would like to point that this article is not against Bloc pattern (definitely not). It is just an advice for those who are arriving in Dart & Flutter side and may be frustrated trying to implement Bloc when they don't need.

Top comments (7)

Collapse
 
arielmejiadev profile image
Ariel Mejia

I started some little time ago I use StreamControllers with rxDart and "Bloc" arquitecture but I notice that in many cases with just native states it goes very well, one thing that its anoying is that there are many "Right ways" and not a one What do you think about handling some easy sections as default stateless and statefull widgets and just the most "complex" add streams and every complex tools?

Collapse
 
rubensdemelo profile image
rubensdemelo

For me, there is no "right ways". There is a way to fit your needs. You do not gonna use the same solution for a todo app and a shopping app. Even if your app has a simple flow, stateful widgets could be a good choice. The packages provider and scoped model works with streams/rx if you need a robust solution. If you feel more comfortable with Redux or mobX, no worries.

Collapse
 
arielmejiadev profile image
Ariel Mejia

Thanks I think that probably streams give me a simple api to work not a basic one just simple, I read that now provider package is the way :D you have experice? and at your experience whats a good source or course for flutter I learned in some Udemy courses and the app brewry ones and some Youtube videos but there are many different approachs :$

Collapse
 
cretezy profile image
Charles Crete

I've been doing a lot of Flutter for the past year, and I've always found BLoC to be a worst Redux. It has the same concept, yet none of the usability.

Native state should always be to go to before going to a global state manager like Redux.

Collapse
 
filipenmarques profile image
Filipe Marques

Great Rubens! Thank you!

Collapse
 
rubensdemelo profile image
rubensdemelo

thanks :)

Collapse
 
olenkavarlaz profile image
Olenka Vargas Lazarte • Edited

Nice, thanks!