FoldingFeature.fromJson constructor
FoldingFeature.fromJson(
- Map<String, dynamic> json
)
Implementation
factory FoldingFeature.fromJson(Map<String, dynamic> json) {
FoldStatus stateFromInt(int state) {
switch (state) {
case 1:
return FoldStatus.expanded;
case 2:
return FoldStatus.folded;
case 3:
return FoldStatus.halfFolded;
default:
return FoldStatus.unknown;
}
}
Axis axisFromInt(int orientation) {
switch (orientation) {
case 1:
return Axis.vertical;
default:
return Axis.horizontal;
}
}
return FoldingFeature(
state: stateFromInt(json['state']),
orientation: axisFromInt(json['orientation']),
bounds: Rect.fromLTRB(
(json['bounds']["left"]).toDouble(),
(json['bounds']["top"]).toDouble(),
(json['bounds']["right"]).toDouble(),
(json['bounds']["bottom"]).toDouble()),
);
}