flutter - 如何在画布上制作自定义可编辑文本框,其中背景随文本传播?
解决方案
这里的代码:
class TextFieldTest extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 50),
child: TextField(
maxLines: 10,
keyboardType: TextInputType.multiline,
textAlign: TextAlign.center,
style: TextStyle(
wordSpacing: 5,
height: 2,
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 26,
background: Paint()
..color = Colors.blue
..style = PaintingStyle.stroke
..strokeWidth = 35
..strokeJoin = StrokeJoin.round,
),
),
),
),
);
}
}
strokeWidth 应大于 fontSize 以按您选择的颜色填充所有文本。
尝试使用它,以便最终获得更准确的结果。
推荐阅读
- regex - 正则表达式引用捕获的组
- php - 如何在单击时查看登录表单输入的控制台输出?
- typescript - “typeof firebase”类型不存在属性“default”。错误
- vuetify.js - 如何在 vuetify 输入字段中调用 click:prepend 事件或 click:append 事件
- matlab - 如何在没有 for 循环的情况下在 Matlab 中获得某个输出?
- wordpress - 如何根据WordPress中的分类术语计算帖子?
- c# - uwp xaml 中是否支持浮点类型?
- ios - 如何在 SwiftUI 中使用 Checkbox 创建文本?
- javascript - 不理解高阶函数(使用 javascript 的问题示例)
- java - OpenJ9 tomcat 不会以高 -Xmx 堆选项启动