Flutter tips and good practices
--
Some tips and good practices to you have a good relationship with flutter!
Hi, today I'm going to write about some tips and good practices to you work with flutter. This article can and will be right opinionated, so if you don't agree with something just ignore, ok? Let's go!
If you have something that could be added to this article, just comment below, let's discuss it.
1. Always use commas:
When you don't put commas at the end of some declaration, and you try to indent your code, it is not going to end good. The indentation process use the commas to break the lines, and without them the code looks like trash, and it is difficult to understand what's happening.
Expanded(
child: InkWell(
onTap: _onAddTap, <---
child: Container(), <---
), <---
), <---
The default value for max characters it is 80, and when you do not use commands, your code feels like a hadouken.
2. Choose the right state management:
Look the needs of your project and your team, do not choose Bloc, Mobx … Or wherever, just because someone said that it is good, you need to think if every one of your team will be comfortable to work with your choice and if your project will scale as you need with the state management that you choose. Each one of them will have pros and cons, so you need to search and have some POCs (proof of concept) to decide which one will fit for your context.
There are a lot of example projects and articles showing different approaches to manage and architect your application, waiting you to find them. Google it!
3. Create widgets lots of widgets:
Everything in flutter is a widget and this is perfect to create reusable codes, do not let your widget or your screen grows and become a massive something. Create widgets of widgets, separate in different methods.
4. Use the LINT:
Add the file analysis_options with the rules that fits to your project, the lint helps you especially when you have more than one dev in the project to have a more organize and concise code, and sometimes when you're writing some…