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