Flutter Android 项目遇见的问题
Gradle build failed to produce an .apk
- 是否设置了flavor了
flutter run --flavor replace_your_flavor_name, 或者在选择入口文件main.dart选项中选择Edit Configurations , Build flavor中填入你的flavor - 是否改变了apk文件输出路径
- 参考资料
插件注册两次或者addActivityResultListener回调两次
插件被Flutter注册了两次,debug排查下就好了
GestureDetector点击空白区域无效
/// How to behave during hit tests.
enum HitTestBehavior {
/// Targets that defer to their children receive events within their bounds
/// only if one of their children is hit by the hit test.
deferToChild,
/// Opaque targets can be hit by hit tests, causing them to both receive
/// events within their bounds and prevent targets visually behind them from
/// also receiving events.
opaque,
/// Translucent targets both receive events within their bounds and permit
/// targets visually behind them to also receive events.
translucent,
}
TabController addListener 调用两次
查看源码
void _changeIndex(int value, { Duration duration, Curve curve }) {
assert(value != null);
assert(value >= 0 && (value < length || length == 0));
assert(duration != null || curve == null);
assert(_indexIsChangingCount >= 0);
if (value == _index || length < 2)
return;
_previousIndex = index;
_index = value;
if (duration != null) {
_indexIsChangingCount += 1;
notifyListeners(); // Because the value of indexIsChanging may have changed.
_animationController
.animateTo(_index.toDouble(), duration: duration, curve: curve)
.whenCompleteOrCancel(() {
_indexIsChangingCount -= 1;
notifyListeners();
});
} else {
_indexIsChangingCount += 1;
_animationController.value = _index.toDouble();
_indexIsChangingCount -= 1;
notifyListeners();
}
}
在动画结束之后还会在调用notifyListeners(),所以会调用两次。
可以根据tabController.indexIsChanging来判断是否需要刷新
开发中的奇怪的现象
Mac AndroidStudio开发环境,偶尔会出现在无论你按什么键都没用,但是切到其他应用都正常,关闭再打开又正常了。下次碰见这种情况你可以看看你AndroidStudio的Terminal是不是正在输入,如果是,关掉就好了。
学习并实际开发中。。。后续继续更新碰见的问题