ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect…

Follow publication

Member-only story

Flutter Best Practices — Part 4

Flutter Best Practices — Part 4

Here are the new set of 5 Best practices to become a pro flutter developer

The other parts of this series links are provided at the end of this article.

1. Use final/const keyword for unmodified variables

“final” means single-assignment: a final variable or field must have an initializer. Once assigned a value, a final variable’s value cannot be changed. final modifies variables.

final should be used over const if you don’t know the value at compile time, and it will be calculated/grabbed at runtime.

if you have a const collection, everything inside of that is in const. If you have a final collection, everything inside of that is not final.

There are lot more differences and examples for more understanding.

// Don’tString firstName = “John”
int a = 1
// Dofinal String firstName = “John”
const int a = 1
//or const a = 1

2. Don’t use ‘+’ for concatenating strings, use string interpolation

// Don't
final String firstName = "John";
final String text = firstName + " Doe"

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Written by Jamie

Flutter, React Native, Android, iOS App developer.

Responses (1)

Write a response