- Notifications
You must be signed in to change notification settings - Fork29.7k
Closed
Labels
P2Important issues not at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)found in release: 1.22Found to occur in 1.22found in release: 1.27Found to occur in 1.27has reproducible stepsThe issue has been confirmed reproducible and is ready to work onperf: speedPerformance issues related to (mostly rendering) speedr: timeoutIssue is closed due to author not providing the requested details in time
Description
Steps to reproduce
Run the following sample will reproduce the issue. I redraw the rect for in the interval of 10 milliseconds. Initially, it slows down, and then it renders with the 10ms speed and then after some time, it slows to draw the rect.
code sample
import'dart:async';import'dart:ui';import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget {@overrideWidgetbuild(BuildContext context) {returnMaterialApp( title:'Flutter Custom Painter', theme:ThemeData( primarySwatch:Colors.pink, ), home:MyPainter(), ); }}classMyPainterextendsStatefulWidget {@override_MyPainterStatecreateState()=>_MyPainterState();}class_MyPainterStateextendsState<MyPainter> {_MyPainterState() { timer=Timer.periodic(constDuration(milliseconds:10), execute); }Timer timer;ValueNotifier<int> repaintNotifier;finalPaint paint=Paint() ..color=Colors.red ..style=PaintingStyle.fill;@overridevoidinitState() { repaintNotifier=ValueNotifier<int>(0);super.initState(); }@overridevoiddispose() { repaintNotifier.dispose();super.dispose(); }@overrideWidgetbuild(BuildContext context) {returnScaffold( appBar:AppBar( title:Text('Polygons'), ), body:CustomPaint( size:Size.infinite,//2 painter:ProfileCardPainter(Colors.red, repaintNotifier, paint),//3 ), ); }voidexecute(Timer timer) {setState(() { repaintNotifier.value++; }); }}classProfileCardPainterextendsCustomPainter {ProfileCardPainter(this.color,this.repaintNotifier,this.paints);Color color;ValueNotifier<int> repaintNotifier;Paint paints;@overridevoidpaint(Canvas canvas,Size size) { repaintNotifier.value.isOdd? canvas.drawRect(Rect.fromLTWH(size.width/2, size.height/2, size.width/2, size.height/2), paints): canvas.drawRect(Rect.fromLTWH(size.width/4, size.height/4, size.width/4, size.height/4), paints); repaintNotifier.value++; }@overrideboolshouldRepaint(covariantCustomPainter oldDelegate)=>true;}
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)found in release: 1.22Found to occur in 1.22found in release: 1.27Found to occur in 1.27has reproducible stepsThe issue has been confirmed reproducible and is ready to work onperf: speedPerformance issues related to (mostly rendering) speedr: timeoutIssue is closed due to author not providing the requested details in time
