0

我的应用程序同时在网络和设备上运行,当收到来自 bloc 的预订状态时,我会显示底部表格显示预订详细信息和 . 在网络上运行应用程序时showModalBottomSheet显示没有问题,但在 iPad 上运行 iOS 版本时,我多次出现 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));
                    }
                  }
4

1 回答 1

0

经过几次尝试,我发现AutoSizeText是负责任的。我猜想group:在屏幕中初始化的参数不会传递给 CupertinoActionSheet ..无论如何我不需要它用于 iOS。

于 2020-07-09T19:34:49.310 回答