Skip to content

AutoSizeText with checkboxes #101

@flipflop133

Description

@flipflop133

Question
How to avoid AutoSizeText trying to resize itself when tapping on a checkbox that is placed in the same row.

Code sample

// Create days boxes widgets
List<Widget> createDaysBoxes() {
   AutoSizeGroup textGroup =
        AutoSizeGroup(); // Keep consistent font size for all days
    List<Widget> daysBoxes = [];
    data.checkedDays.forEach(
      (day, isChecked) {
        daysBoxes.add(
          Expanded(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Expanded(
                  flex: 3,
                  child: Padding(
                    padding: const EdgeInsets.fromLTRB(10, 5, 0, 5),
                    child: AutoSizeText(
                      getDayString(day),
                      group: textGroup,
                      style: const TextStyle(fontSize: 40),
                    ),
                  ),
                ),
                Expanded(
                  child:Checkbox(
                      checkColor: Colors.white,
                      value: data.checkedDays[day]![1],
                      onChanged: (bool? value) {
                        setState(() {
                          data.checkedDays[day]![1] = value!;
                        });
                      },
                    ),
                ),
              ],
            ),
          ),
        );
      },
    );
    return daysBoxes;
  }

Screenshot
image
-> in this screenshot, "Monday" and "Tuesday" are trying to automatically resize their fontsize each time I tap on a checkbox.

Version

  • Flutter version: 2.5.3
  • auto_size_text version: 3.0.0

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions