json_theme 1.0.7
json_theme: ^1.0.7 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.
Alignment
Plain string that must be one of:
bottomCenter==>Alignment.bottomCenterbottomLeft==>Alignment.bottomLeftbottomRight==>Alignment.bottomRightcenter==>Alignment.centercenterLeft==>Alignment.centerLeftcenterRight==>Alignment.centerRighttopCenter==>Alignment.topCentertopLeft==>Alignment.topLefttopRight==>Alignment.topRight
Axis
Plain string that must be one of:
horizontal==>Axis.horizontalvertical==>Axis.vertical
BlendMode
Plain string that must be one of:
clear==>BlendMode.clearcolor==>BlendMode.colorcolorBurn==>BlendMode.colorBurncolorDodge==>BlendMode.colorDodgedarken==>BlendMode.darkendifference==>BlendMode.differencedst==>BlendMode.dstdstATop==>BlendMode.dstATopdstIn==>BlendMode.dstIndstOut==>BlendMode.dstOutdstOver==>BlendMode.dstOverexclusion==>BlendMode.exclusionhardLight==>BlendMode.hardLighthue==>BlendMode.huelighten==>BlendMode.lightenluminosity==>BlendMode.luminositymodulate==>BlendMode.modulatemultiply==>BlendMode.multiplyoverlay==>BlendMode.overlayplus==>BlendMode.plussaturation==>BlendMode.saturationscreen==>BlendMode.screensoftLight==>BlendMode.softLightsrc==>BlendMode.srcsrcATop==>BlendMode.srcATopsrcIn==>BlendMode.srcInsrcOut==>BlendMode.srcOutsrcOver==>BlendMode.srcOverxor==>BlendMode.xor
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
BoxFit
Plain string that must be one of:
contain==>BoxFit.containcover==>BoxFit.coverfill==>BoxFit.fillfitHeight==>BoxFit.fitHeightfitWidth==>BoxFit.fitWidthnone==>BoxFit.nonescaleDown==>BoxFit.scaleDown
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
CrossAxisAlignment
Plain string that must be one of:
baseline==>CrossAxisAlignment.baselinecenter==>CrossAxisAlignment.centerend==>CrossAxisAlignment.endstart==>CrossAxisAlignment.startstretch==>CrossAxisAlignment.stretch
DragStartBehavior
Plain string that must be one of:
down==>DragStartBehavior.downstart==>DragStartBehavior.start
FilterQuality Plain string that must be one of:
high==>FilterQuality.highlow==>FilterQuality.lowmedium==>FilterQuality.mediumnone==>FilterQuality.none
FlexFit
Plain string that must be one of:
loose==>FlexFit.loosetight==>FlexFit.tight
FloatingActionButtonAnimator
Plain string that must be one of:
scaling==>FloatingActionButtonAnimator.scaling
FloatingActionButtonLocation
Plain string that must be one of:
centerDocked==>FloatingActionButtonLocation.centerDockedcenterFloat==>FloatingActionButtonLocation.centerFloatendDocked==>FloatingActionButtonLocation.endDockedendFloat==>FloatingActionButtonLocation.endFloatendTop==>FloatingActionButtonLocation.endTopminiStartTop==>FloatingActionButtonLocation.miniStartTopstartTop==>FloatingActionButtonLocation.startTop
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
Gradient
Requires a type value that must be one of:
linear==>LinearGradientradial==>RadialGradientsweep==>SweepGradient
HitTestBehavior
Plain string that must be one of:
deferToChild==>HitTestBehavior.deferToChildopaque==>HitTestBehavior.opaquetranslucent==>HitTestBehavior.translucent
ImageRepeat
Plain string that must be one of:
noRepeat==>ImageRepeat.noRepeatrepeat==>ImageRepeat.repeatrepeatX==>ImageRepeat.repeatXrepeatY==>ImageRepeat.repeatY
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
MaterialType
Plain string that must be one of:
button==>MaterialType.buttoncanvas==>MaterialType.canvascard==>MaterialType.cardcircle==>MaterialType.circletransparency==>MaterialType.transparency
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
Overflow
Plain string that must be one of:
clip==>Overflow.clipvisible==>Overflow.visible
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
Rect
Requires a type value that must be one of:
center==>Rect.fromCentercircle==>Rect.fromCirclelargest==>Rect.largestltrb==>Rect.fromLTRBltwh==>Rect.fromLTWHpoints==>Rect.fromPointszero==>Rect.zero
ScrollPhysics
Requires a type value that must be one of:
always==>AlwaysScrollableScrollPhysicsbouncing==>BouncingScrollPhysicsclamping==>ClampingScrollPhysicsfixedExtent==>FixedExtentScrollPhysicsnever==>NeverScrollableScrollPhysicspage==>PageScrollPhysics
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
StackFit
Plain string that must be one of:
expand==>StackFit.expandloose==>StackFit.loosepassthrough==>StackFit.passthrough
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
TextAlign
Plain string that must be one of:
center==>TextAlign.centerend==>TextAlign.endjustify==>TextAlign.justifyleft==>TextAlign.leftright==>TextAlign.rightstart==>TextAlign.start
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
TextDirection
Plain string that must be one of:
ltr==>TextDirection.ltrrtl==>TextDirection.rtl
TextOverflow
Plain string that must be one of:
clip==>TextOverflow.clipellipsis==>TextOverflow.ellipsisfade==>TextOverflow.fadevisible==>TextOverflow.visible
TextWidthBasis
Plain string that must be one of:
longestLine==>TextWidthBasis.longestLineparent==>TextWidthBasis.parent
TileMode
Plain string that must be one of:
clamp==>TileMode.clampmirror==>TileMode.mirrorrepeated==>TileMode.repeated
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