草庐IT

customPainter

全部标签

camera - CustomPaint Over Camera Preview

我正在尝试在Flutter中的相机预览上显示CustomPaint元素。现在,CustomPaint元素显示在相机预览下方。我正在使用Fluttercameraplugin显示相机预览。我的代码如下。class_CameraPreviewStateextendsState{[...]Widgetbuild(BuildContextcontext){doubleheight=MediaQuery.of(context).size.height;returnnewYidKitTheme(newCenter(child:_isReady?newContainer(height:height/

android - Flutter Custompainter canvas drawimage 不工作

我尝试使用Canvas和CustomPainter绘制图像,但它不起作用。这是针对使用FlutterFramework的Android应用。我只是在Windowscmd中使用命令flutterbuildapk来构建应用程序。class_MyStatefulWidgetStateextendsState{@overrideWidgetbuild(BuildContextcontext){returnnewScaffold(appBar:AppBar(title:Text('Title!')),body:Center(child:AspectRatio(aspectRatio:1.0,ch

flutter - CustomPainter 使用 Listenable 重绘

CustomPainter类似乎有几种触发重绘的方法。我已经让我的painter使用shouldRepaint方法,但是,我希望我的painter对listenable中的变化使用react,而不是轮询更改。Flutter文档指出Themostefficientwaytotriggerarepaintistoeither:Extendthisclassandsupplyarepaintargumenttotheconstructorof>theCustomPainter,wherethatobjectnotifiesitslistenerswhenitistimetorepaint.E

widget - Flutter CustomPaint 阴影

我有以下小部件:classOutsiderButtonextendsStatelessWidget{finalFunctiononPressed;finalIconicon;finalOutsiderButtonPositionposition;OutsiderButton({this.onPressed,@requiredthis.icon,this.position});@overrideWidgetbuild(BuildContextcontext){returnnewStack(fit:StackFit.loose,alignment:Alignment.center,chil

dart - 我们如何将尺寸传递给 CustomPaint?

Column的子CustomPainter的大小变为(0,0)。1)当我们刚刚使用CustomPaint和CustomPainter时,我们期望的大小被传递给CustomPainter,它按预期呈现。2)当我们使用CustomPaint和CustomPainter作为Stack的child时,我们期望的大小没有传递给CustomPainter。3)但是当我们将它用作SizedBox.expand的子级时,我们期望的大小被传递给CustomPainter并被渲染。4)当我们使用CustomPaint和CustomPainter作为Column的child时,我们期望的大小没有传递给Cus

Flutter:在 CustomPainter 对象上检测触摸进入、移动和退出的正确方法是什么

我是Flutter的初学者,我正在尝试弄清楚当用户将手指滑过自定义形状和/或多个堆叠的自定义形状时如何检测触摸进入、移动和退出。像下面这样的东西理想情况下,我希望在用户进入/退出每个自定义形状的像素边界时获得触摸事件,但我想让它至少与形状的MBR一起工作。下面是我的代码。我究竟做错了什么?它似乎所做的只是在形状内开始触摸时打印移动。我也尝试过GestureDetector,结果相似。import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{//Th

flutter - CustomPaint 在其下方的小部件上绘制。如何避免?

这个问题在这里已经有了答案:Howtotouchpaintacanvas?(2个答案)关闭4年前。我有一个大小为300、300的CustomPaoint。在这个下方我还有其他小部件。我还有一个监听器,用于跟踪向下和移动位置并将偏移量添加到列表中。此列表用于状态更改并发送到CustomPainter进行绘制。一切正常。如果我在CustomPaint小部件的边界外点击,则它不会绘制。但是,如果我点击CustomPaint内部并移出它,那么偏移量将被记录并用于绘画,这会导致在CustomPaint下面的其他小部件中进行绘画。如何避免?下面是我的代码。classDrawingCanvasext

android - 更改 CustomPaint 的颜色会更改所有先前的点

因此,我正在尝试按照“签名Canvas”方法使用Flutter创建一个绘图应用程序。但是,我无法更改CustomPaint对象的颜色,而它在更改之前已经更改了每条线条绘制的颜色,如下所示:如您所见,一旦页面小部件的状态发生变化(通过单击主FAB或再次在Canvas上绘制),颜色就会发生变化。下面是我的DrawPage代码:classDrawPageextendsStatefulWidget{@overrideDrawPageStatecreateState()=>newDrawPageState();}classDrawPageStateextendsStatewithTickerPr

flutter - 如何在指针向下事件的位置绘制 CustomPaint 小部件?

我正在尝试创建一个简单的小部件,以便当用户按下屏幕时,该位置会出现一个圆圈。我有一个由Listener小部件包装的CustomPaint小部件,如下所示:newListener(onPointerDown:down,child:newCustomPaint(painter:painter,size:Size.infinite,),)问题在于指针向下事件是在全局坐标中提供的,而绘画是在CustomPaint小部件的本地坐标中完成的。应该如何转换这两个坐标系?Thispage说我可以使用RenderBox.globalToLocal方法,但是如何获得CustomPaint小部件的Rende

image - Flutter:如何将 Canvas/CustomPainter 保存到图像文件中?

我正在尝试从用户那里收集签名并将其保存到图像中。我已经做到了可以在屏幕上绘图的距离,但现在我想单击一个按钮以保存到图像并存储在我的数据库中。这是我目前所拥有的:import'package:flutter/material.dart';classSignaturePadPageextendsStatefulWidget{SignaturePadPage({Keykey}):super(key:key);@override_SignaturePadPagecreateState()=>new_SignaturePadPage();}class_SignaturePadPageextend