GraphViewport.fromJson constructor
Creates a viewport from JSON data.
Deserializes a viewport from a JSON map. Missing values default to identity viewport (0, 0, 1.0).
Example:
final json = {'x': 100.0, 'y': 50.0, 'zoom': 1.5};
final viewport = GraphViewport.fromJson(json);
Implementation
factory GraphViewport.fromJson(Map<String, dynamic> json) {
return GraphViewport(
x: (json['x'] as num?)?.toDouble() ?? 0.0,
y: (json['y'] as num?)?.toDouble() ?? 0.0,
zoom: (json['zoom'] as num?)?.toDouble() ?? 1.0,
);
}