subhamayd2 / day_night_time_picker

A day night time picker for Flutter. Beautiful day and night animation with Sun and Moon assets.
https://pub.dev/packages/day_night_time_picker
Apache License 2.0
93 stars 82 forks source link

Infinite width error #118

Closed maplepam closed 1 year ago

maplepam commented 1 year ago

Hello, I have the following widget tree.

Expanded
  SingleChildScrollView
    Container
      Column
        TextField
        TextField
        Row
          Expanded
            Column
                TextField
                 **InkWell**
                  TextField
          Expanded
            Column
              TextField
              TextField

From the InkWell on tap function, I added the following codes:

Navigator.of(context).push(
  showPicker(
    context: context,
    isInlinePicker: false,
    value: Time(hour: 0, minute: 0),
    sunrise: TimeOfDay(hour: 6, minute: 0),
    sunset: TimeOfDay(hour: 18, minute: 0),
    iosStylePicker: true,
    duskSpanInMinutes: 120,
    onChangeDateTime: (datetime) {
        setState(() {});
    },
    onChange: (p0) {},
));       

However, I'm getting the following error during build of DayNightTimePickerIos:

Screenshot 2023-09-29 at 10 53 33 PM

I've been trying to figure out how to make this work, but I can't seem even seem to find the root cause. Perhaps you could help me with this problem?

Thanks!

maplepam commented 1 year ago

Update, I've figured it out. The widget causing the error is the ActionButtons class.

I added expanded to each element in row and error no more. :D

return Expanded(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          Expanded(
            child: TextButton(
              style: (timeState.widget.cancelButtonStyle ??
                      timeState.widget.buttonStyle) ??
                  defaultButtonStyle,
              onPressed: timeState.onCancel,
              child: Text(
                timeState.widget.cancelText,
                style: timeState.widget.cancelStyle,
              ),
            ),
          ),
          SizedBox(width: timeState.widget.buttonsSpacing ?? 0),
          Expanded(
            child: TextButton(
              onPressed: timeState.onOk,
              style: timeState.widget.buttonStyle ?? defaultButtonStyle,
              child: Text(
                timeState.widget.okText,
                style: timeState.widget.okStyle,
              ),
            ),
          ),
        ],
      ),
    );