Dart 颤振:为画家类设置背景图像
我需要设置一个背景图像,因为我正在尝试构建一个小部件,帮助孩子们在我的背景图像上画数字和字母 这将是默认的小部件背景: 加载小部件后,孩子们应该能够在背景上画画 我曾试图从官方的画师插件中修改脚手架的主体,但图像没有出现在画师的背景中,它只显示空白屏幕Dart 颤振:为画家类设置背景图像,dart,flutter,background-image,paint,Dart,Flutter,Background Image,Paint,我需要设置一个背景图像,因为我正在尝试构建一个小部件,帮助孩子们在我的背景图像上画数字和字母 这将是默认的小部件背景: 加载小部件后,孩子们应该能够在背景上画画 我曾试图从官方的画师插件中修改脚手架的主体,但图像没有出现在画师的背景中,它只显示空白屏幕 Container( decoration: new BoxDecoration( image: new DecorationImage( image: new ExactAssetImage('assets
Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new ExactAssetImage('assets/test.png'),
fit: BoxFit.cover,
),
),
child: Painter(_controller),
)
是否可以为Painter小部件设置背景图像?如果没有,是否有其他解决方案可以帮助我完成任务?您只需要为
画师使用透明的背景色
PainterController _controller;
@override
void initState() {
_controller = PainterController();
_controller.thickness = 5.0;
_controller.backgroundColor = Colors.transparent;
super.initState();
}
就这样。别担心,记住试着阅读你正在使用的librar的源代码来检查它是如何工作的。