json_theme 1.0.0
json_theme: ^1.0.0 copied to clipboard
A library to dynamically generate a ThemeData object from a JSON file or dynamic map object
json_theme #
Library to encode and decode ThemeData and associated objects to / from JSON. This is currently an early release of the library.
This provides two main classes.
ThemeDecoder-- Provides functionality to decode theme related objects from JSON maps.ThemeEncoder-- Provides functionality to encode theme related objects into JSON maps.
Note: Encoding and decoding is mostly bi-directionally compatible, but it is not fully bi-directionally compatible. That's because there are some properties in theme objects that exist on the constructors, but are not re-exposed as properties and only exposed as dynamic calculated values. Likewise, there are some dynamic classes (specifically custom Shape, Slider, and Decoration classes) that have no meaningful way of being encoded to JSON nor decoded from JSON.
The decoders will throw assert errors when unsupported properties are encountered. The encoders will typically follow a "fail silently" policy and omit unsupported properties that the decoders cannot handle. This means it's safe to pass an encoded JSON map to the decoders, but hand crafted JSON may encounter issues.
Class Selection #
As close as possible, the names used in the Dart APIs are replicated. However, there are instances where the class is different for things like Shape objects, or there's an enum like VerticalDirection. Those are all documented in this section.
BorderRadius
Requires a type value that must be one of:
all==>BorderRadius.allcircular==>BorderRadius.circularhorizontal==>BorderRadius.horizontalonly==>BorderRadius.onlyvertical==>BorderRadius.vertical
BorderStyle
Plain string that must be one of:
none==>BorderStyle.nonesolid==>BorderStyle.solid
BottomNavigationBarType
Plain string that must be one of:
fixed==> BottomNavigationBarType.fixedshifting==> BottomNavigationBarType.shifting
**ButtonBarLayoutBehavior
Plain string that must be one of:
constrained==>ButtonBarLayoutBehavior.constrainedpadded==>ButtonBarLayoutBehavior.padded
ButtonTextTheme
Plain string that must be one of:
accent==>ButtonTextTheme.accentnormal==>ButtonTextTheme.normalprimary==>ButtonTextTheme.primary
Clip
Plain string that must be one of:
antiAlias==>Clip.antiAliasantiAliasWithSaveLayer==>Clip.antiAliasWithSaveLayerhardEdge==>Clip.hardEdgenone==>Clip.none
FloatingLabelBehavior
Plain string that must be one of:
always==>FloatingLabelBehavior.alwaysauto==>FloatingLabelBehavior.autonever==>FloatingLabelBehavior.never
FontWeight
Plain string that must be one of:
bold==>FontWeight.boldnormal==>FontWeight.normalw100==>FontWeight.w100w200==>FontWeight.w200w300==>FontWeight.w300w400==>FontWeight.w400w500==>FontWeight.w500w600==>FontWeight.w600w700==>FontWeight.w700w800==>FontWeight.w800w900==>FontWeight.w900
FontStyle
Plain string that must be one of:
italic==>FontStyle.italicnormal==>FontStyle.normal
InputBorder
Requires a type value that must be one of:
outline==>OutlineInputBorderunderline==>UnderlineInputBorder
InteractiveInkFeatureFactory
Plain string that must be one of:
splash==>InkSplash.splashFactoryripple==>InkRipple.splashFactory
MainAxisAlignment
Plain string that must be one of:
center==>MainAxisAlignment.centerend==>MainAxisAlignment.endspaceAround==>MainAxisAlignment.spaceAroundspaceBetween==>MainAxisAlignment.spaceBetweenspaceEvenly==>MainAxisAlignment.spaceEvenlystart==>MainAxisAlignment.start
MainAxisSize
Plain string that must be one of:
min==>MainAxisSize.minmax==>MainAxisSize.max
MaterialTapTargetSize
Plain string that must be one of:
padded==>MaterialTapTargetSize.paddedshrinkWrap==>MaterialTapTargetSize.shrinkWrap
NavigationRailLabelType
Plain string that must be one of:
all==>NavigationRailLabelType.allnone==>NavigationRailLabelType.noneselected==>NavigationRailLabelType.selected
NotchedShape
Plain string that must be one of:
circular==>CircularNotchedRectangle
Radius
Requires a type value that must be one of:
circular==>Radius.circularelliptical==>Radius.ellipticalzero==>Radius.zero
RangeSliderThumbShape
Requires a type value that must be one of:
round==>RoundRangeSliderThumbShape
RangeSliderTickMarkShape
Plain string that must be one of:
Requires a type value that must be one of:
round==>RoundRangeSliderTickMarkShape
RangeSliderTrackShape
Plain string that must be one of:
rectangular==>RectangularRangeSliderTrackShaperounded==>RoundedRectRangeSliderTrackShape
RangeSliderValueIndicatorShape
Requires a type value that must be one of:
paddle==>PaddleRangeSliderValueIndicatorShape
ShapeBorder
Requires a type value that must be one of:
circle==>CircleBorderrectangle==>ContinuousRectangleBorderrounded==>RoundedRectangleBorder
ShowValueIndicator
Plain string that must be one of:
always==>ShowValueIndicator.alwaysnever==>ShowValueIndicator.neveronlyForContinuous==>ShowValueIndicator.onlyForContinuousonlyForDiscrete==>ShowValueIndicator.onlyForDiscrete
SliderComponentShape
Plain string that must be one of:
noOverlay==>SliderComponentShape.noOverlaynoOverlay==>SliderComponentShape.noOverlay
SliderTrackShape
Plain string that must be one of:
rectangular==>RectangularSliderTrackShaperounded==>RoundedRectSliderTrackShape
SnackBarBehavior
Plain string that must be one of:
fixed==>SnackBarBehavior.fixedfloating==>SnackBarBehavior.floating
TabBarIndicatorSize
Plain string that must be one of:
label==>ButtonTextTheme.labeltab==>ButtonTextTheme.tab
TargetPlatform
Plain string that must be one of:
android==>TargetPlatform.androidfuchsia==>TargetPlatform.fuchsiaiOS==>TargetPlatform.iOSlinux==>TargetPlatform.linuxmacOS==>TargetPlatform.macOSwindows==>TargetPlatform.windows
TextBaseline
Plain string that must be one of:
alphabetic==>TextBaseline.alphabeticideographic==>TextBaseline.ideographic
TextDecoration
Plain string that must be one of:
lineThrough==>TextDecoration.lineThroughnone==>TextDecoration.noneoverline==>TextDecoration.overlineunderline==>TextDecoration.underline
TextDecorationStyle
Plain string that must be one of:
dashed==>TextDecorationStyle.dasheddotted==>TextDecorationStyle.dotteddouble==>TextDecorationStyle.doublesolid==>TextDecorationStyle.solidwavy==>TextDecorationStyle.wavy
VerticalDirection
Plain string that must be one of:
down==>VerticalDirection.downup==>VerticalDirection.up
VisualDensity
Plain string that must be one of:
adaptivePlatformDensity==>VisualDensity.adaptivePlatformDensitycomfortable==>VisualDensity.comfortablecompact==>VisualDensity.compactstandard==>VisualDensity.standard