dropdown_button2
dropdown_button2 copied to clipboard
`DropdownButtonFormField2` doesn't hide its underline.
Consider the code below:
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
class DropDownButtonItemsTest extends StatelessWidget {
const DropDownButtonItemsTest({super.key});
@override
Widget build(BuildContext context) {
return DropdownButtonHideUnderline(
child: DropdownButtonFormField2(
hint: const Text('Items'),
value: null,
items: const [
DropdownMenuItem(
value: 'item1',
child: Text('item1'),
),
DropdownMenuItem(
value: 'item2',
child: Text('item2'),
),
DropdownMenuItem(
value: 'item2',
child: Text('item2'),
),
],
onChanged: (val) {},
),
);
}
}
Was expecting that the Underline inside the DropdownButtonFormField2 would be hidden just like in the DropdownButtonField2.
I also noticed that DropdownButton2 has an option to have underline widget which I could just put SizedBox() inside which solves the problem without having a parent of DropdownButtonHideUnderline eliminating unnecessary widget nesting.
Can someone help me on this?
As you are using DropdownButtonFormField2 you can simply hide the underline by adding InputDecoration,.
DropdownButtonFormField2<String>(
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide.none,
),
),
)
just add above code in your DropdownButtonFormField2