CupertinoActionSheet throws RenderBox was not laid out: RenderFlex#54b93 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE error Flutter

Issue

My app runs both on web and device, and when receiving a booking state from bloc I show a bottom sheet show booking details and . When running the app on web showModalBottomSheet shows without problems, but when running the iOS version on iPad I get multiple times the
RenderBox was not laid out: RenderFlex#54b93 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE exception.
Can you spot what I’m missing to do for the CupertinoActionSheet ?

I construct them as:

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));
                    }
                  }

Solution

After a few tries I found AutoSizeText be the responsible. I guess that group: parameter as it’s initialized in in the screen doesn’t get passed to CupertinoActionSheet..anyways I don’t need it for iOS.

Answered By – Vincenzo

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.