osum_serializable 0.0.2 osum_serializable: ^0.0.2 copied to clipboard
Serialize almost everything you ever need! Supports serializing `Color`, `DateTime`, `Directory`, `File`, `Duration`, and many more.
osum_serializable #
The goal is to serialize almost everything you ever need! json_serializable
is an amazing package to serialize classes but cannot serialize complex types. This package supports serializing Color
, DateTime
, Directory
, File
, Duration
, and many more.
Supports #
Types | Support |
---|---|
Color |
✅ |
DateTime |
✅ |
Directory |
✅ |
File |
✅ |
Duration |
✅ |
How to use? #
// imports ...
part 'test.g.dart';
@JsonSerializable()
class Example {
const Example(this.directory, this.file, this.color);
factory Example.fromJson(Json json) => _$ExampleFromJson(json);
@DirectoryConverter() // <- Converters provided by osum_serializable!
final Directory directory;
@FileConverter()
final File file;
@ColorConverter()
final Color color;
Json toJson() => _$ExampleToJson(this);
}