toJson method
Implementation
@override
Map<String, dynamic>? toJson(ScrollPhysics? value) {
if (value == null) return null;
String? type;
if (value is AlwaysScrollableScrollPhysics) {
type = 'always';
} else if (value is BouncingScrollPhysics) {
type = 'bouncing';
} else if (value is ClampingScrollPhysics) {
type = 'clamping';
} else if (value is FixedExtentScrollPhysics) {
type = 'fixedExtent';
} else if (value is NeverScrollableScrollPhysics) {
type = 'never';
} else if (value is PageScrollPhysics) {
type = 'page';
} else if (value is RangeMaintainingScrollPhysics) {
type = 'rangeMaintaining';
}
if (type == null) {
throw Exception(
'Unknown ScrollPhysics class encounted: ${value.runtimeType}');
}
return {
'parent': const NullableScrollPhysicsConverter().toJson(value.parent),
'type': type,
};
throw 'Json_Unsuported_Value';
}