cv 0.2.13 copy "cv: ^0.2.13" to clipboard
cv: ^0.2.13 copied to clipboard

Content Values map helpers. Define objects that can be converted to/from maps.

example/main.dart

import 'package:cv/cv.dart';

class Note extends CvModelBase {
  final title = CvField<String>('title');
  final content = CvField<String>('content');
  final date = CvField<DateTime>('date');

  @override
  List<CvField> get fields => [title, content, date];
}

void main() {
  var note = Note()
    ..title.v = 'My note'
    ..content.v = 'My note context'
    ..date.v = DateTime(2021, 08, 16);
  print(note.toMap());

  note = Note()
    ..fromMap({
      'title': 'My other note',
      'content': 'My other note context',
      'date': DateTime(2021, 08, 18)
    });
  print(note.toMap());

  // Add the builder once
  cvAddBuilder<Note>((_) => Note());

  // Any map can be converted to a note object
  note = {'title': 'My note from a map'}.cv<Note>();
  print(note.toMap());

  note = {'title': 'My other note from a map', 'content': 'With some content'}
      .cv<Note>();
  print(note.toMap());
}
14
likes
0
pub points
83%
popularity

Publisher

verified publishertekartik.com

Content Values map helpers. Define objects that can be converted to/from maps.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, meta

More

Packages that depend on cv