flutter - Flutter中如何改变ListView的overscroll发光效果颜色?

Flutter 中如何更改 ListView 的发光效果颜色?

最佳答案

在这里阅读 GlowingOverscrollIndicator似乎您可以更改 ThemeData.accentColor 的值来更改过度滚动发光颜色。

您可以尝试使用类似的方法将 Theme 更改限制为仅 ListView

//store the current Theme to restore it later
final ThemeData defaultTheme = Theme.of(context);

Theme(
  //Inherit the current Theme and override only the accentColor property
  data: Theme.of(context).copyWith(
    accentColor: Colors.yellow
  ),
  child: ListView.builder(
      //suppose data it's an array of strings
      itemBuilder: (BuildContext context, int index) =>
          EntryItem(data[index], defaultTheme),
      itemCount: data.length,
  ),
);

//this is your class to render rows
class EntryItem extends StatelessWidget {
  const EntryItem(this.entry, this.defaultTheme);

  final String entry;
  final ThemeData defaultTheme;

  Widget _buildTiles(String entry) {
    return Theme(
      data: defaultTheme,
      child: Text(entry)
    );
  }

  @override
  Widget build(BuildContext context) {
    return _buildTiles(entry);
  }
}

You can read more about how to style your Theme here

https://stackoverflow.com/questions/52710761/

相关文章:

facebook - 如何在 Flutter 应用中实现分享按钮?

testing - Flutter:如何加载文件进行测试

flutter - 在 initState 中调用 SetState 的重要性

dart - 使用 NetworkImage 进行 Flutter 小部件测试

flutter - child : and children: property in Flutte

regex - 如何从 Dart 中的字符串中仅删除符号

datetime - 如何到达 Dart 的最后一个午夜?

flutter - 如何创建返回小部件数组的函数

dart - Flutter 自定义动画对话框

dart - Flutter Android PreferenceScreen 设置页面