我正在使用 DropDowmMenu 中的搜索模式。 所以我们可以通过写入一些值来过滤 itens。 当我们单击箭头打开列表项时,我需要自动清理我们编写的内容。
可能吗?我尝试了 inkweel 但没有,总是只有下拉列表中的事件被触发。来自 inkwell 的 Ontap 永远不会被触发。
但即使有效,这也不是一个好方法,因为只有当我们打开项目列表时,这个想法才会被激发。当我们单击右侧的箭头时,就会发生这种情况。
谢谢!
Container(
//padding: const EdgeInsets.symmetric(horizontal: 8),
height: 40,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(10.0)),
color: Theme.of(context).colorScheme.secondary,
),
width: double.infinity,
child:
DropdownMenu<Models>(
label: Text(translation(context)!.dropModel),
dropdownMenuEntries: dropdownModelsItems,
requestFocusOnTap: true,
onSelected: dropDownModelsCallBack,
enableSearch: true,
controller: modelController,
enableFilter: true,
menuStyle: const MenuStyle(
alignment: Alignment.bottomLeft,
maximumSize:
MaterialStatePropertyAll(Size.fromHeight(400)),
),
expandedInsets: const EdgeInsets.symmetric(horizontal: 0),
inputDecorationTheme: InputDecorationTheme(
isDense: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 10),
constraints: const BoxConstraints(minWidth: 300, maxWidth: 700, maxHeight: 40),
fillColor: Colors.red,
//filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
),
尝试下面的代码与堆栈...
Container(
height: 40,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(10.0)),
color: Colors.white,
),
width: double.infinity,
child: Stack(
alignment: Alignment.centerRight,
children: [
Container(
margin: EdgeInsets.only(right: 10),
child: InkWell(
onTap: () {
print("Clickkkkk");
},
child: Icon(
Icons.arrow_circle_right_sharp,
color: Colors.black,
),
),
),
Container(
width: MediaQuery.of(context).size.width,
child: DropdownMenu(
label: Text("dropModel"),
requestFocusOnTap: true,
enableSearch: true,
enableFilter: true,
menuStyle: const MenuStyle(
alignment: Alignment.bottomLeft,
maximumSize: MaterialStatePropertyAll(Size.fromHeight(400)),
),
expandedInsets: const EdgeInsets.symmetric(horizontal: 0),
inputDecorationTheme: InputDecorationTheme(
isDense: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 10),
constraints: const BoxConstraints(minWidth: 300, maxWidth: 700, maxHeight: 40),
fillColor: Colors.red,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
dropdownMenuEntries: [],
),
),
],
),
)