问题:在一个Android原生的弹框里显示flutter view,由于使用了Expanded导致组件未显示出来
最神奇的地方在于debug调试模式显示正常,然后用release版本发布时怎么都显示不出来,还导致点击后无响应ANR
问题代码:
- child: StatefulBuilder(
- builder: (context, setState) {
- return Expanded(
- child: Container(
- padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
- decoration: BoxDecoration(
- borderRadius: newStyle
- ? const BorderRadius.only(
- topLeft: Radius.circular(12),
- topRight: Radius.circular(12),
- bottomLeft: Radius.circular(0),
- bottomRight: Radius.circular(0),
- )
- : BorderRadius.circular(4),
- color: themeData.fillBase),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: _buildSettingColumn(),
- ),
- ),
- );
- },
- ),
修改后代码:
- child: StatefulBuilder(
- builder: (context, setState) {
- return Container(
- width: 200,
- padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
- decoration: BoxDecoration(
- borderRadius: newStyle
- ? const BorderRadius.only(
- topLeft: Radius.circular(12),
- topRight: Radius.circular(12),
- bottomLeft: Radius.circular(0),
- bottomRight: Radius.circular(0),
- )
- : BorderRadius.circular(4),
- color: themeData.fillBase),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: _buildSettingColumn(),
- ),
- );
- },
- ),
总结:自己挖的坑给自己上了一课,过程中最困难的是release版本有问题时难以定位,最后还是回退代码才发现的。