AhmedLSayed9 / dropdown_button2

Flutter's core Dropdown Button widget with steady dropdown menu and many other features.
https://pub.dev/packages/dropdown_button2
MIT License
264 stars 122 forks source link

The splash effect goes above the error / validation text #262

Open VinhNgT opened 4 months ago

VinhNgT commented 4 months ago

Currently on version 2.3.9:

Screenshot_20240424-113319_Drive Ready

Expected: The splash effect should stay inside the button border

Here is the code for the above widget, please note that I am using flutter_hooks:

class ChapterDropdown extends HookConsumerWidget {
  final GlobalKey<FormState>? formKey;
  const ChapterDropdown({super.key, this.formKey});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final selected = useState<Chapter?>(null);

    return Form(
      key: formKey,
      child: DropdownButtonFormField2(
        isExpanded: true,
        value: selected.value,
        onChanged: (value) => {
          selected.value = value,
          formKey?.currentState!.reset(),
        },
        hint: Text(
          'Chọn chương',
          style: context.textTheme.bodyLarge!.copyWith(
            color: context.materialScheme.onSurfaceVariant,
          ),
        ),
        validator: (value) {
          if (value == null) {
            return 'Vui lòng chọn chương để xoá';
          }
          return null;
        },
        items: Chapter.values
            .map(
              (item) => DropdownMenuItem(
                value: item,
                child: Text(
                  item.chapterName,
                  style: const TextStyle(
                    fontSize: 14,
                  ),
                ),
              ),
            )
            .toList(),
      ),
    );
  }
}