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

About the author 

Matt Rešetár

Matt is an app developer with a knack for teaching others. Working as a Flutter freelancer and most importantly developer educator, he doesn't have a lot of free time 😅 Yet he still manages to squeeze in tough workouts 💪

You may also like

Flutter Bloc & Cubit Tutorial

Flutter Custom & Staggered Page Transition Animation Tutorial

  • 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


  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}