CupertinoActionSheet 抛出 RenderBox 未布局:RenderFlex#54b93 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 错误 Flutter
CupertinoActionSheet throws RenderBox was not laid out: RenderFlex#54b93 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE error Flutter
我的应用程序同时在网络和设备上运行,当从 bloc 收到预订状态时,我会在底部显示 sheet 显示预订详细信息和 。当 运行 Web showModalBottomSheet
上的应用程序显示没有问题时,但是当 运行 iOS 版本 iPad 时,我得到了多次
RenderBox was not laid out: RenderFlex#54b93 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
异常。
你能找出我为 CupertinoActionSheet
做的事情吗?
我将它们构建为:
if (state is BookingsChanged) {
// show booking info pannel
if (UniversalPlatform.isIOS) {
final action = CupertinoActionSheet(
title: AutoSizeText(
AppLocalizations.instance
.text('${state.type} Booking'),
style: TextStyle(fontSize: 25),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
message: AutoSizeText(
sprintf(AppLocalizations.instance.text('Date:'), [
dateOnlyFormat.format(
DateTime.fromMillisecondsSinceEpoch(
state.booking.bookingDate))
]) +
'\n' +
sprintf(AppLocalizations.instance.text('At:'), [
timeFormat.format(
DateTime.fromMillisecondsSinceEpoch(
state.booking.bookingStart))
]) +
'\n' +
sprintf(
AppLocalizations.instance.text('Customer:'),
[state.booking.customerName]) +
'\n' +
sprintf(AppLocalizations.instance.text('Works:'),
[state.booking.worksNameList]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Booking price'),
[state.booking.bookingPrice]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
color: Colors.black87,
fontWeight: FontWeight.w400),
minFontSize: 10,
maxLines: 4,
group: autoSizeGroup,
),
cancelButton: CupertinoActionSheetAction(
child: AutoSizeText(
AppLocalizations.instance.text('Close'),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
onPressed: () {
Navigator.pop(context);
},
),
);
showCupertinoModalPopup(
context: context, builder: (modal) => action);
} else {
//Android
showModalBottomSheet(
context: context,
builder: (modal) => Container(
padding: EdgeInsets.symmetric(horizontal: 200),
color: Colors.white,
child: Container(
decoration: BoxDecoration(
color: Colors.white, //.white,
borderRadius:
BorderRadius.all(Radius.circular(20)),
),
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SizedBox(
height: 10,
),
AutoSizeText(
AppLocalizations.instance
.text('${state.type} Booking'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
color: Colors.black87,
fontWeight: FontWeight.w400,
),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
SizedBox(
height: 10,
),
AutoSizeText(
sprintf(
AppLocalizations.instance
.text('Date:'),
[
dateOnlyFormat.format(DateTime
.fromMillisecondsSinceEpoch(
state
.booking.bookingDate))
]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('At:'),
[
timeFormat.format(DateTime
.fromMillisecondsSinceEpoch(
state.booking
.bookingStart))
]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Customer:'),
[state.booking.customerName]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Works:'),
[state.booking.worksNameList]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Price:'),
[state.booking.bookingPrice]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
color: Colors.black87,
fontWeight: FontWeight.w400),
minFontSize: 10,
maxLines: 4,
group: autoSizeGroup,
),
SizedBox(
height: 10,
),
FlatButton(
color: Colors.redAccent,
child: AutoSizeText(
AppLocalizations.instance.text('Close'),
style: TextStyle(
fontSize: 30, color: Colors.white),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
onPressed: () {
print('Cancel button pressed');
Navigator.pop(context);
},
),
SizedBox(
height: 10,
),
],
),
),
),
),
);
}
// TODO Send push to customer
if (state.type == "New") {
// send booking received push
BlocProvider.of<PushNotificationBloc>(context).add(
BookingReceivedPushNotification(
booking: state.booking));
// TODO Update booking state
BlocProvider.of<BookingBloc>(context).add(
UpdateBookingState(
user: widget.user,
booking: state.booking,
state: 'Received',
cityDb: widget.cityDb,
regionDb: widget.regionDb,
countryDb: widget.countryDb));
} else {
// send cancellation received push
BlocProvider.of<PushNotificationBloc>(context).add(
BookingCancellationReceivedPushNotification(
booking: state.booking));
}
}
经过几次尝试,我发现 AutoSizeText
是罪魁祸首。我猜 group:
参数在屏幕中初始化时不会传递给 CupertinoActionSheet..反正我不需要它 iOS.
我的应用程序同时在网络和设备上运行,当从 bloc 收到预订状态时,我会在底部显示 sheet 显示预订详细信息和 。当 运行 Web showModalBottomSheet
上的应用程序显示没有问题时,但是当 运行 iOS 版本 iPad 时,我得到了多次
RenderBox was not laid out: RenderFlex#54b93 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
异常。
你能找出我为 CupertinoActionSheet
做的事情吗?
我将它们构建为:
if (state is BookingsChanged) {
// show booking info pannel
if (UniversalPlatform.isIOS) {
final action = CupertinoActionSheet(
title: AutoSizeText(
AppLocalizations.instance
.text('${state.type} Booking'),
style: TextStyle(fontSize: 25),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
message: AutoSizeText(
sprintf(AppLocalizations.instance.text('Date:'), [
dateOnlyFormat.format(
DateTime.fromMillisecondsSinceEpoch(
state.booking.bookingDate))
]) +
'\n' +
sprintf(AppLocalizations.instance.text('At:'), [
timeFormat.format(
DateTime.fromMillisecondsSinceEpoch(
state.booking.bookingStart))
]) +
'\n' +
sprintf(
AppLocalizations.instance.text('Customer:'),
[state.booking.customerName]) +
'\n' +
sprintf(AppLocalizations.instance.text('Works:'),
[state.booking.worksNameList]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Booking price'),
[state.booking.bookingPrice]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
color: Colors.black87,
fontWeight: FontWeight.w400),
minFontSize: 10,
maxLines: 4,
group: autoSizeGroup,
),
cancelButton: CupertinoActionSheetAction(
child: AutoSizeText(
AppLocalizations.instance.text('Close'),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
onPressed: () {
Navigator.pop(context);
},
),
);
showCupertinoModalPopup(
context: context, builder: (modal) => action);
} else {
//Android
showModalBottomSheet(
context: context,
builder: (modal) => Container(
padding: EdgeInsets.symmetric(horizontal: 200),
color: Colors.white,
child: Container(
decoration: BoxDecoration(
color: Colors.white, //.white,
borderRadius:
BorderRadius.all(Radius.circular(20)),
),
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SizedBox(
height: 10,
),
AutoSizeText(
AppLocalizations.instance
.text('${state.type} Booking'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
color: Colors.black87,
fontWeight: FontWeight.w400,
),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
SizedBox(
height: 10,
),
AutoSizeText(
sprintf(
AppLocalizations.instance
.text('Date:'),
[
dateOnlyFormat.format(DateTime
.fromMillisecondsSinceEpoch(
state
.booking.bookingDate))
]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('At:'),
[
timeFormat.format(DateTime
.fromMillisecondsSinceEpoch(
state.booking
.bookingStart))
]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Customer:'),
[state.booking.customerName]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Works:'),
[state.booking.worksNameList]) +
'\n' +
sprintf(
AppLocalizations.instance
.text('Price:'),
[state.booking.bookingPrice]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
color: Colors.black87,
fontWeight: FontWeight.w400),
minFontSize: 10,
maxLines: 4,
group: autoSizeGroup,
),
SizedBox(
height: 10,
),
FlatButton(
color: Colors.redAccent,
child: AutoSizeText(
AppLocalizations.instance.text('Close'),
style: TextStyle(
fontSize: 30, color: Colors.white),
minFontSize: 10,
maxLines: 1,
group: autoSizeGroup,
),
onPressed: () {
print('Cancel button pressed');
Navigator.pop(context);
},
),
SizedBox(
height: 10,
),
],
),
),
),
),
);
}
// TODO Send push to customer
if (state.type == "New") {
// send booking received push
BlocProvider.of<PushNotificationBloc>(context).add(
BookingReceivedPushNotification(
booking: state.booking));
// TODO Update booking state
BlocProvider.of<BookingBloc>(context).add(
UpdateBookingState(
user: widget.user,
booking: state.booking,
state: 'Received',
cityDb: widget.cityDb,
regionDb: widget.regionDb,
countryDb: widget.countryDb));
} else {
// send cancellation received push
BlocProvider.of<PushNotificationBloc>(context).add(
BookingCancellationReceivedPushNotification(
booking: state.booking));
}
}
经过几次尝试,我发现 AutoSizeText
是罪魁祸首。我猜 group:
参数在屏幕中初始化时不会传递给 CupertinoActionSheet..反正我不需要它 iOS.