我想創建看起來像我提到的下拉串列,但我無法實作我的方面結果
我嘗試使用渲染框來制作自定義下拉選單,但它想要感覺像實際的下拉選單
誰能幫我得到這種結果
我想要這樣的結果:-

我現在的 ui 看起來像這樣:-

這是我的代碼:-
class AppDropDown extends StatefulWidget {
AppDropDown({
Key? key,
required this.dropDownList,
required this.selected,
this.text = "",
}) : super(key: key);
final List<String> dropDownList;
String selected;
final String text;
@override
State<PerytonDropDown> createState() => _PerytonDropDownState();
}
class _PerytonDropDownState extends State<PerytonDropDown> {
@override
Widget build(BuildContext context) {
return Card(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.sp),
),
child: Material(
borderRadius: BorderRadius.circular(15.sp),
clipBehavior: Clip.antiAlias,
color: Colors.transparent,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.text.isNotEmpty) (8.0).addHSpace(),
if (widget.text.isNotEmpty) "${widget.text}".grayText(),
SizedBox(
height: 40,
child: DropdownButton<String>(
isExpanded: true,
value: widget.selected,
underline: SizedBox(),
onChanged: (String? value) {
print(value);
setState(() {
widget.selected = value!;
});
},
alignment: Alignment.bottomRight,
borderRadius: BorderRadius.circular(15),
items: widget.dropDownList
.map((item) => DropdownMenuItem(
child: Text(
item,
),
value: item,
))
.toList(),
),
)
],
).pSymmetricOnly(horizontal: 10),
),
);
}
}
uj5u.com熱心網友回復:
你使用dropdown_below了
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/407456.html
標籤:
