Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 颤振:为画家类设置背景图像_Dart_Flutter_Background Image_Paint - Fatal编程技术网

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的源代码来检查它是如何工作的。