Skip to content
pubscout

cv

1.1.15, released 11 days ago by tekartik.com

Helpers to convert Dart objects to/from Map and JSON without code generation.

WASM-ready
$ flutter pub add cv
Source repository

What it does

cv provides a lightweight way to define models with fields and convert them to maps or JSON. It supports nested models, lists, maps, dates, enums and multi‑type fields, all without code generation.

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

Use it when

  • You need quick, mutable models that map to JSON or Map for local storage or API payloads.
  • You want to avoid build_runner or codegen tooling for simple data structures.
  • You need to handle null and unset values explicitly in your models.

Skip it when

  • Your data models are large and complex, requiring performance optimisations or immutability.
  • You rely heavily on code generation for type safety and boilerplate reduction (e.g., freezed).

Strengths

  • No code generation required
  • Easy to register and use models
  • Handles null/unset values and type conversions
  • Supports nested models and collections

Weaknesses

  • Requires manual constructor registration
  • Models are mutable, which may not fit all architectures
  • No built‑in immutability or validation

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
4

Add dependency, register constructors with cvAddConstructor or cvAddConstructors before converting maps or JSON.

import 'package:cv/cv.dart';

class Todo extends CvModelBase {
  final title = CvField<String>('title');
  final done = CvField<bool>('done');
  @override
  CvFields get fields => [title, done];
}

void main() {
  cvAddConstructor(Todo.new);
  var todo = Todo()..title.v = 'Buy milk';
  print(todo.toMap()); // {title: Buy milk}
  var fromMap = {'title': 'Call Bob', 'done': true}.cv<Todo>();
  print(fromMap.done.v); // true
}

Alternatives

Packages that do the same job and could replace cv.

Works with

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