Built Value Tutorial for Dart & Flutter


Data classes, immutability, simple serialization – this is what Dart does NOT offer right off the bat. While Dart is surely one of the better languages with regards to its simplicity, it currently lacks the support for value types.

When you compare two objects of the same type with identical contents, they will still turn out to be not equal – by default, Dart checks for referential equality, not value equality. Making a copy of an object is also painful – you have so much code to write… And serialization? Oh, even more repetitive code for you!

Well, not with built_value library. It will save you so much time by allowing you to write good quality code without all the repetition.

👉Get the code from this tutorial👈


Dart built_value snippets

Icons made by Becris from www.flaticon.com is licensed by CC 3.0 BY
Matej Rešetár

Matej is an app developer with a knack for teaching others. If he's not programming, making tutorials or doing other business, he's mostly working out, listening to audiobooks and taking cold showers.

  • João Vicente (BRA) says:

    Hi Matej, congratulations! Excellent material about ‘built_value’!

    I have a question.

    How could i implement a named constructor like this: “MyClass.fromMap(String data) {…}’

    Look at the example below, i have a custom initialization to the field ‘userRole’:

    Home.fromMap(Map data) {
    this.companyCode = data[‘companyCode’];
    this.companyName = data[‘companyName’];
    this.companyLogo = data[‘companyLogo’];
    this.userRole = UserRole.valueOf(data[‘userEmail’]); // data[‘userEmail’] returns the userRole string


  • Sebastian says:

    Here is the intellj LiveTemplets version for the snippets:

  • Silver Story says:

    Your the best! Keep it up!

  • >