Serialize almost everything you ever need! 📦 Supports serializing MaterialColor, Color, Size, Locale, IconData, UuidValue, DateTime, Directory, File, Duration, and many more.

Overview

osum_serializable

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 provides convertors for these types. Check the supported types to know more.

Supported types

Type Support Type Support
Color ✅ MaterialColor ✅
Offset ✅ Size ✅
Directory ✅ File ✅
DateTime ✅ IconData ✅
Duration ✅ UuidValue ✅
Locale ✅

How it works

Code Json

How to use?

Install

osum_serializable depends on build_runner and json_serializable to building the toJson and fromJson implementations. To install run these commands in your terminal.

flutter pub add --dev build_runner
flutter pub add --dev json_serializable
flutter pub add osum_serializable

Usage

To use the convertors, simply postfix the data type name with Convertor and call the annotation.

@{DATATYPE}Converter()
final {DATATYPE} variable;

For example, serializing IconData can be done like this.

@IconDataConverter()
final IconData variable;

Example

Refer the example section for the full code.

// imports ...
part 'test.g.dart';

@JsonSerializable()
class Example {
  const Example(this.directory, this.file, this.color, this.duration, this.materialColor);

  factory Example.fromJson(Json json) => _$ExampleFromJson(json);

  @DirectoryConverter() // <- Convertors provided by osum_serializable!
  final Directory directory;

  @MaterialColorConverter()
  final MaterialColor materialColor;

  @FileConverter()
  final File file;

  @ColorConverter()
  final Color color;

  @DurationConverter()
  final Duration duration;

  Json toJson() => _$ExampleToJson(this);
}

Finally, don't forget to call the build_runner to generate the json implementation.

flutter pub run build_runner build
You might also like...

A demonstration of using Riverpod for dynamic locale switching in-app, with persistence.

A demonstration of using Riverpod for dynamic locale switching in-app, with persistence.

Riverpod Localization A demonstration of using Riverpod for dynamic locale switching in-app, with persistence. How It Works Fallback Locale: Declared

Oct 6, 2022

Mobile app for small food business have more results spending almost nothing.

ilunch Mobile app for small food business have more results spending almost nothing. Getting Started This project is a starting point for a Flutter ap

Nov 17, 2022

ThemeX is an easy theme manipulation. Only inform primary color and the ThemeX generate all color combination palette for you

ThemeX is an easy theme manipulation. Only inform primary color and the ThemeX generate all color combination palette for you

ThemeX is an easy theme manipulation basied on Material Design. Only inform primary color and the ThemeX generate all color combination palette for yo

Jan 31, 2022

Material color picker, you can customize colors. Selection in two step, first main color and after shades.

Material color picker, you can customize colors. Selection in two step, first main color and after shades.

Flutter Material Color Picker Material Color picker is a Flutter widget, that can be customizable. By default, it's Material Colors, but you can defin

Nov 25, 2022

A package can help you to change your flutter app's statusbar's color or navigationbar's color programmatically.

A package can help you to change your flutter app's statusbar's color or navigationbar's color programmatically.

flutter_statusbarcolor A package can help you to change your flutter app's statusbar's color or navigationbar's color programmatically. Getting Starte

Nov 10, 2022

Choose color theme template - A template will help you choose a color scheme for the application, show how widgets interact with it

Choose color theme template - A template will help you choose a color scheme for the application, show how widgets interact with it

choose_color_theme_template This template will help you choose a color scheme fo

Oct 24, 2022

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

A customizable carousel slider for Flutter. Supports infinite sliding, custom indicators, and custom animations with many pre-built indicators and animations.

Flutter Carousel Slider A customizable carousel slider for flutter Screenshots Installing dependencies: flutter_carousel_slider: ^1.0.8 Demo Demo a

Nov 6, 2022

Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.

Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.

HtmlWidget monorepo This repo contains the source code for everything HtmlWidget-related. Name Link flutter_widget_from_html_core flutter_widget_from_

Jan 6, 2023

Ozzie is your testing friend. Ozzie will take an screenshot during integration tests whenever you need. Ozzie will capture performance reports for you.

Ozzie is your testing friend. Ozzie will take an screenshot during integration tests whenever you need. Ozzie will capture performance reports for you.

ozzie.flutter Ozzie is your testing friend. Ozzie will take an screenshot during integration tests whenever you need. Ozzie will capture performance r

Nov 3, 2022
Owner
Aswin Murali
Building tools that make your life better!
Aswin Murali
Ever want to create a quick form without wiring everything up? This might be the library for you.

Ever want to create a quick form without wiring everything up? This might be the library for you.

Adam Hammer 15 Sep 13, 2022
The one and only Docker Tool you will ever need again

# container_tool A new Flutter project. ## Getting Started This project is a starting point for a Flutter application. A few resources to get you

null 1 Nov 17, 2021
Dart duration iso parser - Package to parse duration from ISO 8601 string

duration_iso_parser Package for parsing ISO 8601 durations string to the Duratio

Innim 1 Jan 18, 2022
An app to show everything bus related in Singapore, including arrival times and a directory

NextBus SG An app to show everything bus related in Singapore, including bus arrival times and a directory, with extra features. ?? Gallery Click here

null 103 Sep 13, 2022
Flutter video compress - Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.

flutter_video_compress Generate a new path by compressed video, Choose to keep the source video or delete it by a parameter. Get video thumbnail from

天海るり 179 Dec 8, 2022
A CLI tool and Dart package that can scrape file and directory URLs from h5ai instances.

h5ai scraper A CLI tool and Dart package that can scrape file and directory URLs from h5ai instances. Usage This tool requires the Dart SDK. It can be

null 1 Jan 4, 2023
Automatically generate profile picture with random first name and background color. But you can still provide pictures if you have them. As the default color, based on the name of the first letter. :fire: :fire: :fire:

FLUTTER PROFILE PICTURE Automatically generate profile picture with random first name and background color. But you can still provide pictures if you

Aditya Dharmawan Saputra 10 Dec 20, 2022
State Persistence - Persist state across app launches. By default this library store state as a local JSON file called `data.json` in the applications data directory. Maintainer: @slightfoot

State Persistence Persist state across app launches. By default this library store state as a local JSON file called data.json in the applications dat

Flutter Community 70 Sep 28, 2022
Esizer - A Flutter package provide responsive, dynamic, configurable size for each device screen size

ESizer A Flutter package provide responsive, dynamic, configurable size for each

Extreme Vietnam Public 1 Feb 15, 2022
You can create a star easily and decide how many angle or color of the star, even the fat and progress of the star.

You can create a star easily and decide how many angle or color of the star, even the fat and progress of the star.

张风捷特烈 20 Apr 14, 2021