flutter如何覆盖第三方组件样式?
比如我现在这个tdesign的ui库的底部弹框的标题文字大小设置小一点,但是我看ui库文档api并没有,
那我如何跟vue一样能v-deep这样强制改变呢
flutter如何覆盖第三方组件样式?
比如我现在这个tdesign的ui库的底部弹框的标题文字大小设置小一点,但是我看ui库文档api并没有,
那我如何跟vue一样能v-deep这样强制改变呢
1.像tdesign的ui这样的Ui库如果真的没有修改的属性可以尝试
下面这种方法。。TDTheme.of(context).copyWith...或者Theme.of(context).copyWith...
@override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(
textTheme: Theme.of(context).textTheme.copyWith(
titleLarge: TextStyle(
fontSize: 24,
color: Colors.blue,
fontWeight: FontWeight.bold,
),
),
),
child: Scaffold(
appBar: AppBar(
title: Text("修改后的 AppBar 标题"),
),
body: Center(
child: Text(
"正文内容",
style: Theme.of(context).textTheme.bodyLarge,
),
),
),
);
}
使用copyWith方法能够在保证其他属性不变的情况下,只改变你想改的内容;通过Theme包含子组件又能在覆盖子组件的部分样式而不影响全局的;这是flutter一种机制;
2 回答2.1k 阅读✓ 已解决
2 回答808 阅读✓ 已解决
1 回答748 阅读✓ 已解决
1 回答1.4k 阅读
1 回答1.3k 阅读
2 回答1k 阅读
2 回答988 阅读
或者自定义: