Skip to content
pubscout

dart_mappable_builder

4.10.1, released 8 days ago by schultek.dev

Builder that generates dart_mappable code for JSON serialization and data classes.

$ flutter pub add dart_mappable_builder
Source repository

What it does

Generates mapping code for classes annotated with @MappableClass, handling generics, inheritance, and primary constructors. It integrates with build_runner to produce efficient, type‑safe serializers.

AI-written summary of version 4.10.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need compile‑time JSON (de)serialization with support for generics and inheritance.
  • You want a code‑gen alternative to manual toJson/fromJson implementations.
  • You prefer a single annotation‑based approach over multiple boilerplate files.

Skip it when

  • You prefer a runtime‑only solution without build steps.
  • Your project cannot add build_runner or code‑gen dependencies.

Strengths

  • Full support for generics, inheritance and primary constructors
  • Highly customizable via annotations
  • Fast runtime performance because code is generated

Weaknesses

  • Requires build_runner and code generation step
  • Only works for Dart (no native platform plugins)

Setup

Kind
Pure Dart
Effort
Medium
Code generation
Yes (build_runner)
Direct dependencies
9

Add dart_mappable_builder to dev_dependencies, configure build_runner, and run `flutter pub run build_runner build`.

import 'package:dart_mappable/dart_mappable.dart';

@MappableClass()
class User with UserMappable {
  final String name;
  final int age;
  const User(this.name, this.age);
}

void main() {
  final user = User('Alice', 30);
  final json = user.toJson();
  final restored = UserMapper.fromMap(json);
  print(restored);
}

Alternatives

Packages that do the same job and could replace dart_mappable_builder.

  • json_annotation

    Provides annotation‑based JSON serialization with json_serializable, a widely used alternative.

  • freezed_annotation

    Generates immutable data classes and JSON support via freezed, also uses build_runner.

  • built_value

    Offers immutable value types with serialization, suitable for complex models.

Works with

Packages commonly used together with dart_mappable_builder: ones it builds on, ones built on it, and its own family.