diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e34c9..30b1b5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.2.2+1 +- fix: graph crash, when there is no panelBuilder. + ## 0.2.2 - fix: [#6](https://github.com/graph-cn/flutter_graph_view/issues/6) - change the loading timing of the panel to be at the same time as vertex/edge components loading. diff --git a/example/pubspec.lock b/example/pubspec.lock index f2d5ea1..e976be3 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -76,7 +76,7 @@ packages: path: ".." relative: true source: path - version: "0.2.1" + version: "0.2.2" flutter_lints: dependency: "direct dev" description: @@ -90,22 +90,6 @@ packages: description: flutter source: sdk version: "0.0.0" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "04be76c4a4bb50f14904e64749237e541e7c7bcf7ec0b196907322ab5d2fc739" - url: "https://pub.dev" - source: hosted - version: "9.0.16" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: b06739349ec2477e943055aea30172c5c7000225f79dad4702e2ec0eda79a6ff - url: "https://pub.dev" - source: hosted - version: "1.0.5" lints: dependency: transitive description: @@ -126,18 +110,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.10.0" ordered_set: dependency: transitive description: @@ -215,14 +199,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 - url: "https://pub.dev" - source: hosted - version: "13.0.0" web: dependency: transitive description: diff --git a/examples/execution_plan/pubspec.lock b/examples/execution_plan/pubspec.lock index 62b7995..ee00a79 100644 --- a/examples/execution_plan/pubspec.lock +++ b/examples/execution_plan/pubspec.lock @@ -76,7 +76,7 @@ packages: path: "../.." relative: true source: path - version: "0.2.1" + version: "0.2.2" flutter_lints: dependency: "direct dev" description: @@ -90,22 +90,6 @@ packages: description: flutter source: sdk version: "0.0.0" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "04be76c4a4bb50f14904e64749237e541e7c7bcf7ec0b196907322ab5d2fc739" - url: "https://pub.dev" - source: hosted - version: "9.0.16" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: b06739349ec2477e943055aea30172c5c7000225f79dad4702e2ec0eda79a6ff - url: "https://pub.dev" - source: hosted - version: "1.0.5" lints: dependency: transitive description: @@ -126,18 +110,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.10.0" ordered_set: dependency: transitive description: @@ -215,14 +199,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 - url: "https://pub.dev" - source: hosted - version: "13.0.0" web: dependency: transitive description: diff --git a/lib/widgets/edge_component.dart b/lib/widgets/edge_component.dart index 45905c7..1f6716e 100644 --- a/lib/widgets/edge_component.dart +++ b/lib/widgets/edge_component.dart @@ -37,6 +37,8 @@ class EdgeComponent extends ShapeComponent Duration get panelDelay => gameRef.options.panelDelay ?? const Duration(milliseconds: 300); + bool get hasPanel => gameRef.options.edgePanelBuilder != null; + @override FutureOr onLoad() { hitBox = edgeShape.hitBox(edge, this); @@ -47,10 +49,10 @@ class EdgeComponent extends ShapeComponent void loadOverlay() { var panelBuilder = gameRef.options.edgePanelBuilder; - if (panelBuilder == null) return; + if (!hasPanel) return; gameRef.overlays.addEntry(overlayName, (_, game) { - return panelBuilder(edge, gameRef.camera.viewfinder); + return panelBuilder!(edge, gameRef.camera.viewfinder); }); } @@ -75,7 +77,9 @@ class EdgeComponent extends ShapeComponent void onHoverEnter() { paint.strokeWidth = 4; gameRef.graph.hoverEdge = edge; - gameRef.overlays.add(overlayName); + if (hasPanel) { + gameRef.overlays.add(overlayName); + } } @override @@ -91,8 +95,10 @@ class EdgeComponent extends ShapeComponent void onHoverExit() { paint.strokeWidth = 1; gameRef.graph.hoverEdge = null; - Future.delayed(panelDelay, () { - gameRef.overlays.remove(overlayName); - }); + if (hasPanel) { + Future.delayed(panelDelay, () { + gameRef.overlays.remove(overlayName); + }); + } } } diff --git a/lib/widgets/vertex_component.dart b/lib/widgets/vertex_component.dart index e1fd014..34aa703 100644 --- a/lib/widgets/vertex_component.dart +++ b/lib/widgets/vertex_component.dart @@ -52,6 +52,8 @@ class VertexComponent extends ShapeComponent Duration get panelDelay => gameRef.options.panelDelay ?? const Duration(milliseconds: 300); + bool get hasPanel => gameRef.options.vertexPanelBuilder != null; + @override FutureOr onLoad() { if (options?.enableHit != false) { @@ -64,10 +66,10 @@ class VertexComponent extends ShapeComponent void loadOverlay() { var panelBuilder = gameRef.options.vertexPanelBuilder; - if (panelBuilder == null) return; + if (!hasPanel) return; gameRef.overlays.addEntry(overlayName, (_, game) { - return panelBuilder(vertex, gameRef.camera.viewfinder); + return panelBuilder!(vertex, gameRef.camera.viewfinder); }); } @@ -116,15 +118,19 @@ class VertexComponent extends ShapeComponent @override void onHoverEnter() { graph.hoverVertex = vertex; - gameRef.overlays.add(overlayName); + if (hasPanel) { + gameRef.overlays.add(overlayName); + } } @override void onHoverExit() { graph.hoverVertex = null; - Future.delayed(panelDelay, () { - gameRef.overlays.remove(overlayName); - }); + if (hasPanel) { + Future.delayed(panelDelay, () { + gameRef.overlays.remove(overlayName); + }); + } } @override diff --git a/pubspec.yaml b/pubspec.yaml index 8b180f3..f4b5725 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_graph_view description: Widgets for beautiful graphic data structures, such as force-oriented diagrams. -version: 0.2.2 +version: 0.2.2+1 homepage: https://github.com/dudu-ltd/flutter_graph_view environment: