Skip to main content

flutter_class_parser 0.2.6 copy "flutter_class_parser: ^0.2.6" to clipboard
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 #

  1. Color
  2. Orientation
  3. BlendMode
  4. TileMode
  5. Alignment
  6. BoxFit
  7. ImageRepeat
  8. FilterQuality
  9. StackFit
  10. FontWeight
  11. FontStyle
  12. Axis
  13. AxisDirection
  14. TextDecoration
  15. TextDecorationStyle
  16. Clip
  17. Curve
  18. TextOverflow
  19. TextDirection
  20. TextAlign
  21. TextBaseline
  22. MainAxisAlignment
  23. CrossAxisAlignment
  24. WrapAlignment
  25. WrapCrossAlignment
  26. MainAxisSize
  27. VerticalDirection
  28. BorderStyle
  29. StrokeJoin
  30. StrokeCap
  31. Offset
  32. Size
  33. Rect
  34. EdgeInsets
  35. Radius
  36. BorderRadius
  37. Matrix4
  38. SystemMouseCursor
  39. Gradient
  40. Shadow
  41. ImageFilter
  42. ColorFilter
  43. DecorationImage
  44. BoxDecoration
  45. 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.mode and ColorFilter.matrix.
  • ImageProvider parsing (used by DecorationImage) supports NetworkImage and AssetImage.
  • BoxDecoration parsing supports color, gradient and image.
  • 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.

5
likes
150
points
6.56k
downloads

Documentation

API reference

Publisher

verified publisherwenkaifan.com

Weekly Downloads

A package for serialize and deserialize common UI data classes in Flutter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_class_parser