颤动下拉按钮按下时删除灰色

Yun*_*lik 2 dart flutter flutter-layout flutter-animation

当我选择下拉按钮的值时,我想删除这个灰色按钮。我该怎么做。我尝试了一切 这是我的代码

InputDecorator(
      decoration: const InputDecoration(
        border: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(4.0))),
        contentPadding: EdgeInsets.all(10),
      ),
      child: DropdownButtonHideUnderline(
        child: DropdownButton<dynamic>(
          value: null,
          isDense: true,
          hint: Text(hintText),
          isExpanded: true,
          items: itemList,
          onChanged: (newValue) {},
        ),
      ),
    ),
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

lep*_*sch 6

您可以通过将每个小部件包裹在小部件周围来设置每个小部件的主题Theme以更改InkWell效果。这种方式不会改变MaterialApp.theme整个应用程序的行为,而不是改变全局InkWell。因此,只需更改,和 即可。ThemeData highlightColorhoverColorsplashColor

检查以下结果:

截屏

InputDecorator(
  decoration: const InputDecoration(
    border: OutlineInputBorder(
        borderRadius: BorderRadius.all(Radius.circular(4.0))),
    contentPadding: EdgeInsets.all(10),
  ),
  child: Theme(                           // <- Here
    data: Theme.of(context).copyWith(     // <- Here
      splashColor: Colors.transparent,    // <- Here
      highlightColor: Colors.transparent, // <- Here
      hoverColor: Colors.transparent,     // <- Here
    ),
    child: DropdownButtonHideUnderline(
      child: DropdownButton<String>(
        value: selectedValue,
        isDense: true,
        isExpanded: true,
        focusColor: Colors.transparent,
        items: const [
          DropdownMenuItem(value: '1', child: Text('menu1')),
          DropdownMenuItem(value: '2', child: Text('menu2')),
          DropdownMenuItem(value: '3', child: Text('menu3')),
          DropdownMenuItem(value: '4', child: Text('menu4')),
        ],
        onChanged: (newValue) => setState(() => selectedValue = newValue),
      ),
    ),
  ),
),
Run Code Online (Sandbox Code Playgroud)