Flutter:自定义ExpansionTile [英] Flutter: Custom ExpansionTile

查看:881
本文介绍了Flutter:自定义ExpansionTile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在颤动中更改扩展图块?具体来说,我想删除它在扩展时创建的分隔线。我也想调整其填充。那可能吗?谢谢!

Is it possible to alter the expansion tile in flutter? Specifically I want to remove the dividers it creates when it expands. Also I want to adjust its padding. Is that possible? Thanks!

推荐答案

ExpansionTile

https://github.com/flutter/flutter/blob/d927c9331005f81157fa39dff7b5dab415ad330b/packages/flutter/lib/src/material/expansion_tile.dart#L176-L184

  Widget build(BuildContext context) {
    final ThemeData theme = Theme.of(context);
    _borderColor.end = theme.dividerColor;
    _headerColor
      ..begin = theme.textTheme.subhead.color
      ..end = theme.accentColor;
    _iconColor
      ..begin = theme.unselectedWidgetColor
      ..end = theme.accentColor;
    _backgroundColor.end = widget.backgroundColor;

您可以通过将元素包装在 Theme ,例如修改 dividerColor

you can derive what you can influence by wrapping the element in a Theme for example by modifying dividerColor

_borderColor.end = theme.dividerColor;





final theme = Theme.of(context).copyWith(dividerColor: Colors.yellow);
return Theme(data: theme, child: ExpansionTile(...));     

_headerColor _iconColor _backgroundColor
如果需要更多自定义,则可以随时复制源并将其自定义为自己的喜好。

similar with _headerColor, _iconColor, _backgroundColor. If you need more customization, you can always copy the source and customize it to your liking.

这篇关于Flutter:自定义ExpansionTile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆