flutter-implement-json-serialization

Installation
SKILL.md

Contents

Core Guidelines

  • Import dart:convert: Use jsonEncode() and jsonDecode() for manual serialization.
  • Type Safety: Always cast jsonDecode() result to Map<String, dynamic> (objects) or List<dynamic> (arrays). Never work with raw dynamic.
  • Encapsulation: Define fromJson factory constructor and toJson method within the model class.
  • Background Parsing: Offload to a separate isolate via compute() if parsing takes > 16ms (large JSON payloads).
  • Error Handling: Throw FormatException on invalid JSON. Never return null from fromJson.

Dart 3 Pattern Matching in fromJson

Installs
6
GitHub Stars
20
First Seen
13 days ago
flutter-implement-json-serialization — dhruvanbhalara/skills