Skip to content

Commit

Permalink
v0.2.2+1 fix: graph crash, when there is no panelBuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
CorvusYe committed Mar 26, 2024
1 parent b0eb074 commit fe15737
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 71 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
34 changes: 5 additions & 29 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.1"
version: "0.2.2"
flutter_lints:
dependency: "direct dev"
description:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
34 changes: 5 additions & 29 deletions examples/execution_plan/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ packages:
path: "../.."
relative: true
source: path
version: "0.2.1"
version: "0.2.2"
flutter_lints:
dependency: "direct dev"
description:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
18 changes: 12 additions & 6 deletions lib/widgets/edge_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> onLoad() {
hitBox = edgeShape.hitBox(edge, this);
Expand All @@ -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);
});
}

Expand All @@ -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
Expand All @@ -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);
});
}
}
}
18 changes: 12 additions & 6 deletions lib/widgets/vertex_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> onLoad() {
if (options?.enableHit != false) {
Expand All @@ -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);
});
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit fe15737

Please sign in to comment.