Need help tracing down an error #16
Unanswered
iyaanbarry
asked this question in
Q&A
Replies: 2 comments 11 replies
-
Hello, @iyaanbarry This is also the problem I have been trying to find out. It seems like I missed some details about the flame somewhere, causing a situation similar to dividing by 0 to occur. |
Beta Was this translation helpful? Give feedback.
4 replies
-
Thank you so much for looking into the issue.
I’ll really appreciate it if it can be resolved by next Monday.
…On Sun, Oct 13, 2024 at 5:27 PM 大叶 ***@***.***> wrote:
*EXTERNAL EMAIL : *Exercise caution when responding, opening links,
or opening attachments.
Okay, I have reproduced the problem you encountered.
I will try my best to fix it as soon as possible.
Do you have any important time points in your project.
—
Reply to this email directly, view it on GitHub
<#16 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5UIMJVOH6HJ7RXYFY4M3H3Z3LQT5AVCNFSM6AAAAABP3X5LCGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAOJTGA4DANA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I must say that you guys have done an excellent job in creating this library. I'm having an issue trying to trace down a crash I end up facing sometimes. I has to do something with the number of nodes and causes the application to crash after a few minutes.
Can someone please help me figure out the cause?
I get the following error:
_AssertionError ('dart:ui/painting.dart': Failed assertion: line 36 pos 10: '': Offset argument contained a NaN value.)
In this file:
// Copyright (c) 2023- All flutter_graph_view authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.
import 'dart:math';
import 'dart:ui' as ui;
import 'package:flame/collisions.dart';
import 'package:flutter/material.dart';
import 'package:flutter_graph_view/core/util.dart';
import 'package:flutter_graph_view/flutter_graph_view.dart';
/// The default edge shape impl.
///
/// 默认使用 直线做边。
class EdgeLineShape extends EdgeShape {
@OverRide
render(Edge edge, Canvas canvas, Paint paint, List paintLayers) {
if (edge.isLoop) {
vertexSame(edge, canvas, paint);
} else {
vertexDifferent(edge, canvas, paint);
}
}
void vertexDifferent(Edge edge, ui.Canvas canvas, ui.Paint paint) {
var startPoint = Offset.zero;
var endPoint = Offset(len(edge), paint.strokeWidth);
}
void vertexSame(Edge edge, ui.Canvas canvas, ui.Paint paint) {
Path path = loopPath(edge);
canvas.drawPath(path, paint);
edge.path = path;
}
Path loopPath(Edge edge, [double minusRadius = 0]) {
var idx = edge.edgeIdx;
var radius = (idx + 1) * edge.start.radius * 1.5;
Path path = Path();
path.addArc(
Rect.fromCircle(
center: Offset(radius, 0),
radius: radius - minusRadius / edge.cpn!.game.camera.viewfinder.zoom),
0,
-2 * pi,
);
}
@OverRide
void setPaint(Edge edge) {
var paint = edge.cpn!.paint;
paint.strokeWidth = edge.isHovered ? 4 : 1.2;
paint.strokeWidth /= edge.cpn!.game.camera.viewfinder.zoom;
paint.style = PaintingStyle.stroke;
var startPoint = Offset.zero;
var endPoint = Offset(len(edge), paint.strokeWidth);
var hoverOpacity = edge.cpn?.gameRef.options.graphStyle.hoverOpacity ?? .5;
if (isWeaken(edge)) {
paint.shader = ui.Gradient.linear(
startPoint,
endPoint,
List.generate(
2,
(index) => [
(edge.start.colors.last).withOpacity(hoverOpacity),
(edge.end?.colors.last ?? Colors.white).withOpacity(hoverOpacity)
][index],
),
);
} else {
paint.shader = ui.Gradient.linear(
startPoint,
endPoint,
List.generate(
2,
(index) => [
edge.start.colors.last,
(edge.end?.colors.last ?? Colors.white)
][index],
),
);
}
}
@OverRide
double height(Edge edge) {
return 3.0;
}
@OverRide
ShapeHitbox? hitBox(Edge edge, EdgeComponent edgeComponent) {
return null;
}
@OverRide
bool? hoverTest(Vector2 point, Edge edge, EdgeComponent edgeComponent) {
var offset = Offset(point.x, point.y);
var hoverStrokeWidth = (edge.isHovered ? 2.0 : 1.2);
if (edge.isLoop) {
return edge.path!.contains(offset) &&
!loopPath(edge, hoverStrokeWidth).contains(offset);
} else {
if (edge.computeIndex == 0) {
return null;
}
Path? minusArea = edge.path?.shift(Offset(
0,
edge.computeIndex > 0 ? -hoverStrokeWidth : hoverStrokeWidth,
));
return ((edge.path?.contains(offset) ?? false) &&
(!(minusArea?.contains(offset) ?? true)));
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions