当我的应用程序以发布模式启动时,我遇到了一个相当奇怪的错误:
我按照这个PageView答案使用和保留我的 BottomNavigationBar 的页面AutomaticKeepAliveClientMixin。在调试模式下,不会发生此错误。
home.dart
import 'package:flutter/material.dart';
import 'package:lottery_rewards/controller.dart';
class HomeView extends StatefulWidget {
const HomeView({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _HomeView();
}
class _HomeView extends State<HomeView>
with AutomaticKeepAliveClientMixin<HomeView> {
@override
Widget build(BuildContext context) {
super.build(context);
return Column(
children: [
const MainAppBar(),
Expanded(
child: Center(
child: TextButton(
child: const Text('Home'),
onPressed: () {
},
),
),
)
],
);
}
@override
bool get wantKeepAlive => true;
}
Run Code Online (Sandbox Code Playgroud)
同样在终端中,它显示“对空值使用空检查运算符”,但是我不知道在哪里使用了这段代码。
I/flutter (29449): Null check …Run Code Online (Sandbox Code Playgroud)