nank1ro / flutter-shadcn-ui

shadcn-ui ported in Flutter. Awesome UI components for Flutter, fully customizable.
https://flutter-shadcn-ui.mariuti.com
MIT License
1.14k stars 64 forks source link

Select component child list has a different size than its parent #146

Closed renanboni closed 1 month ago

renanboni commented 1 month ago

Hey, I noticed that when we have a select component, the list that is open when I click on it doesn't have the same size as the parent:


ResponsiveRowColumnItem(
          child: ResponsiveRowColumn(
            layout: ResponsiveBreakpoints.of(context).smallerThan(DESKTOP)
                ? ResponsiveRowColumnType.COLUMN
                : ResponsiveRowColumnType.ROW,
            rowSpacing: 12,
            columnSpacing: 12,
            children: [
              ResponsiveRowColumnItem(
                rowFlex: 1,
                child: ShadSelectFormField<Category>(
                  id: 'category',
                  minWidth: double.infinity,
                  placeholder: const Text(""),
                  label: const Text('Categories (optional)'),
                  initialValue: null,
                  onChanged: (value) {},
                  options: categories
                      .map(
                        (e) => ShadOption(
                          value: e,
                          child: Text(e.name),
                        ),
                      )
                      .toList(),
                  selectedOptionBuilder: (context, value) => Text(value.name),
                ),
              ),
              ResponsiveRowColumnItem(
                rowFlex: 1,
                child: ShadSelectFormField<String>(
                  id: 'tags',
                  minWidth: double.infinity,
                  label: const Text('Tags (optional)'),
                  initialValue: "",
                  onChanged: (value) {},
                  options: [],
                  selectedOptionBuilder: (context, value) => const Text(""),
                ),
              ),
            ],
          ),
        )
Screenshot 2024-09-19 at 22 42 21
nank1ro commented 1 month ago

Don't use minWidth: double.infinity, leave the default, or wrap with LayoutBuilder and use constraints.maxWidth

renanboni commented 1 month ago

wrapping it with LayoutBuilder solves this, closing!