我注意到我的项目中出现了新的 lint 问题。
长话短说:
我需要在我的自定义类中使用 BuildContext
flutter lint 工具与 aysnc 方法一起使用时并不满意。
例子:
MyCustomClass{
final buildContext context;
const MyCustomClass({required this.context});
myAsyncMethod() async {
await someFuture();
# if (!mounted) return; << has no effect even if i pass state to constructor
Navigator.of(context).pop(); # << example
}
}
Run Code Online (Sandbox Code Playgroud) dart flutter flutter-dependencies flutter-state flutter-build