[英]Flutter Dismissable widget onDismissed doesn't fire
我有 3 个部分,一个是包含 Dismissible 小部件的 ClassList 小部件。 ClassList 有 _refreshGPA function 参数,称为 setState() 方法来重建屏幕。 因此,当 onDismissed 被触发时,ClassList 小部件调用的 _refreshGPA 方法和列表项被正确删除。 每件事都在工作。
body: Column(
children: <Widget>[
_buildClassForm(context),
GPAHeader(gpa: gpa),
ClassList(_classList, _refreshGPA),
],
),
因此,我尝试使用 OrientationBuilder 为横向模式进行布局。 我为每种布局模式实现了两种方法。 但是现在,在两种布局模式下都不会删除列表项。
body: OrientationBuilder(
builder: (context, orientation) {
if (orientation == Orientation.portrait) {
return _bodyPortraitMode(context);
} else {
return _bodyLandscapeMode(context);
}
},
),
Widget _bodyPortraitMode(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
_buildClassForm(context),
GPAHeader(gpa: gpa),
ClassList(_classList, _refreshGPA),
],
),
);
Widget _bodyLandscapeMode(BuildContext context) {
return Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: _buildClassForm(context),
flex: 1,
),
Expanded(
child: Column(
children: <Widget>[
GPAHeader(gpa: gpa),
ClassList(_classList, _refreshGPA),
],
),
flex: 1,
)
],
),
);
我通过传递给身体单独尝试了这两种方法,并且工作正常。 但是当被 OrientationBuilder 包裹时,列表项不会被移除。
谢谢你的帮助,对不起我的拼写错误。 英。 不是我的主要语言。
基于此页面https://github.com/flutter/flutter/issues/48290 ,我为每种布局模式生成 Scaffold 小部件,然后在 if-else 块中返回。 我希望它可以帮助某人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.