Roaa 🦄💙 Profile picture
Software Engineer @widgetbook_io | #Flutter/Dart @GoogleDevExpert | 📃 https://t.co/MnhXzeHUZK

Dec 26, 2021, 7 tweets

Class constructors in #Dart
With some #Flutter use cases 💙

1️⃣ Generative Constructors
2️⃣ Constant Constructors
3️⃣ Named Constructors
4️⃣ Redirecting Constructors
5️⃣ Factory Constructors

A thread 🧵
#DartDev #FlutterDev #OOP

1️⃣ Generative Constructor
Most common form, initializes Class variables

2️⃣ Constant Constructors
It lets you create compile-time constants. This is especially important to create constant widgets in your Flutter app for better performance.

3️⃣ Named Constructors
Lets you create multiple constructors. For example, you can use named constructors to create multiple variations of your widgets

4️⃣ Redirecting Constructors
Has an empty body and calls the main constructor.

5️⃣ Factory Constructors
Used for complex properties initializations.

And there's the default constructor, which is a no-argument constructor generated when no constructor is declared.

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling