flutter - 有没有办法从我的列表图 block 中删除启动画面?

标签 flutter dart

我有以下列表图块

  Container buildContactTile(BuildContext context, Color backgroundColor, Color foregroundColor, UserModel contact,
      ContactListController controller) {
    final ThemeData theme = Theme.of(context);

    return Container(
      decoration: BoxDecoration(color: backgroundColor, borderRadius: const BorderRadius.all(Radius.circular(5.0))),
      child: ListTile(
        leading: ProfileAvatar(
          backgroundColor: foregroundColor,
          photoURL: contact.photoURL,
          radius: 15.0,
          fallback: ProfileAvatar.nameAvatar(displayName: contact.displayName),
        ),
        title: Text(contact.displayName, style: theme.textTheme.bodyText1.apply(color: foregroundColor)),
        trailing: _interactive ? Icon(Icons.add, color: foregroundColor) : null,
        onTap: () => _interactive ? controller.updateSelectedContacts(contact) : null,
      ),
    );
  }
然后用容器包装它,以根据小部件的状态为其提供不同的背景颜色。但是发生的是我的启动画面没有考虑圆形边界半径,因此启动画面颜色最终出现在列表图块的角上。如何使飞溅的颜色透明或解决圆角?
按住ListTile时,您会在角落看到以下内容
enter image description here

最佳答案

将整个Container包装在Theme中,然后将ThemeDatasplashColorhighlightColor设置为Colors.transparent
引用How to disable default Widget splash effect in Flutter?

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Theme(
      data: ThemeData(
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
      ),
      child: Container(
        decoration: BoxDecoration(
          color: Colors.blueGrey,
          borderRadius: const BorderRadius.all(Radius.circular(15.0)),
        ),
        child: ListTile(
          leading: const Icon(Icons.flight_land),
          title: const Text("Trix's airplane"),
          subtitle: const Text('The airplane is only in Act II.'),
          enabled: true,
          onTap: () {
            print('Something');
          },
        ),
      ),
    );
  }
}

关于flutter - 有没有办法从我的列表图 block 中删除启动画面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62639773/

相关文章:

firebase - 如何为Map <String,dynamic>类型的映射添加值?

dart - 多个小部件与 TabController 使用相同的 GlobalKey

dart - 在Polymer Dart中,如何使用表的1个聚合物元素以及行和单元格的另一个聚合物元素构建CSS表

dart - Flutter:测试是否抛出了特定的异常

json - 在 Flutter 中将 Json 数组转换为 List<Object>

react-native - 是否可以构建一个 24/7 运行在后台的 APP?

Flutter 状态管理 (BloC) : Stateless vs Stateful widget

flutter - Flutter:如何销毁HTTP队列请求?

firebase - 如何从引用文档 (Firebase) 中的字段获取字符串数据

flutter - 如何为 Flutter Web 应用程序设置标题和图标?