Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug环境下Hook设置了默认参数的构造函数崩溃 #41

Closed
ljg-7f opened this issue Apr 23, 2020 · 1 comment
Closed

Debug环境下Hook设置了默认参数的构造函数崩溃 #41

ljg-7f opened this issue Apr 23, 2020 · 1 comment

Comments

@ljg-7f
Copy link

ljg-7f commented Apr 23, 2020

Hook的代码:
@call("package:flutter/src/widgets/gesture_detector.dart", "GestureDetector",
"+GestureDetector")
@pragma("vm:entry-point")
static dynamic GestureDetector(PointCut pointcut) {
print('[KWLM-ljg]: Hook GestureDetector Constructor!');
return pointcut.proceed();
}


系统GestureDetector的构造函数:
GestureDetector({
Key key,
this.child,
this.onTap,
...
this.excludeFromSemantics = false,
this.dragStartBehavior = DragStartBehavior.start,
}) : assert(excludeFromSemantics != null),
assert(dragStartBehavior != null),
assert(() {
...
}


分析处理后的dill文件
return new ges::GestureDetector::•(
key: this.namedParams. as key::Key*,
child: this.namedParams. as fra::Widget*,
onTap: this.namedParams. as () →* void,
...
excludeFromSemantics: this.namedParams. as core::bool*,
dragStartBehavior: this.namedParams. as rec::DragStartBehavior*,
$creationLocationd_0dea112b090073317d4: this.namedParams. as wid::_Location*);

excludeFromSemantics和dragStartBehavior赋值为null。
测试debug环境是有问题的,release是正常的,因为release会删除assert。
在debug手动配置默认值后也是正常的,代码如下:

static dynamic GestureDetector(PointCut pointcut) {
print('[KWLM-ljg]: Hook GestureDetector Constructor!');
pointcut.namedParams['excludeFromSemantics'] = false;
pointcut.namedParams['dragStartBehavior'] = DragStartBehavior.start;
return pointcut.proceed();
}

希望能优化该问题。

@kangwang1988
Copy link
Contributor

Try aspectd 1.0.0 for flutter @stable v1.22.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants