Skip to content
pubscout

json_serializable_mobx

1.1.3, released 10 months ago by demoda.app

Extends json_serializable to support MobX collections like ObservableList, ObservableSet, and ObservableMap.

$ flutter pub add json_serializable_mobx
Source repository

What it does

It adds support for serializing and deserializing MobX collections using the json_serializable code generation tool. It acts as an extension to allow seamless handling of reactive collections in data models.

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

Use it when

  • You are using MobX in your Flutter application and need to serialize models containing ObservableList, ObservableSet, or ObservableMap.
  • You already rely on json_serializable for your JSON parsing boilerplate.

Skip it when

  • You are not using MobX for state management.
  • You prefer manual JSON serialization or a different code generation library like built_value.

Strengths

  • Bridges MobX collections with json_serializable seamlessly.
  • Reduces manual mapping boilerplate for reactive types.

Weaknesses

  • Requires custom build.yaml configuration to avoid conflicts with standard json_serializable.
  • Unofficial package dependent on json_serializable internals.

Setup

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

Requires adding to dev_dependencies and configuring build.yaml to exclude standard json_serializable builders and avoid conflicts.

targets:
  $default:
    builders:
      json_serializable_mobx:
        options:
          explicit_to_json: true
      json_serializable:json_serializable:
        generate_for:
          include:
          exclude:
            - test/**
            - lib/**

Alternatives

Packages that do the same job and could replace json_serializable_mobx.

  • built_value

    Alternative code generation system for immutable values and JSON serialization.

Works with

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