flutter_class_parser 0.2.6
flutter_class_parser: ^0.2.6 copied to clipboard
A package for serialize and deserialize common UI data classes in Flutter.
flutter_class_parser #
A package for serialize and deserialize common UI data classes in Flutter.
Getting Started #
To serialize/deserialize a supported class, use:
var gradient = LinearGradient(colors: [Colors.red, Colors.blue]);
String gradientJson = json.encode(gradient.toJson());
var gradient2 = parseGradient(json.decode(gradientJson));
Serialization of built in classes is done using extension methods. Deserialization, on the other hand, is done with functions.
The package only depends on the Flutter widgets library, so it works with both package:flutter/material.dart
and the standalone material_ui package.
Current Supported Classes #
- Color
- Orientation
- BlendMode
- TileMode
- Alignment
- BoxFit
- ImageRepeat
- FilterQuality
- StackFit
- FontWeight
- FontStyle
- Axis
- AxisDirection
- TextDecoration
- TextDecorationStyle
- Clip
- Curve
- TextOverflow
- TextDirection
- TextAlign
- TextBaseline
- MainAxisAlignment
- CrossAxisAlignment
- WrapAlignment
- WrapCrossAlignment
- MainAxisSize
- VerticalDirection
- BorderStyle
- StrokeJoin
- StrokeCap
- Offset
- Size
- Rect
- EdgeInsets
- Radius
- BorderRadius
- Matrix4
- SystemMouseCursor
- Gradient
- Shadow
- ImageFilter
- ColorFilter
- DecorationImage
- BoxDecoration
- TextStyle
Some class parsing are not fully supported yet. For example:
- Curve parsing only supports the predefined curves.
- SystemMouseCursor parsing only supports the predefined cursors.
- ImageFilter parsing supports blur filters and color filters.
- ColorFilter parsing supports
ColorFilter.modeandColorFilter.matrix. - ImageProvider parsing (used by DecorationImage) supports
NetworkImageandAssetImage. - BoxDecoration parsing supports
color,gradientandimage. - TextStyle parsing supports the color, background color, font family, size, weight and style, letter and word spacing, text baseline, height and the decoration properties.
You are more than welcomed to contribute and add more classes to the collection.