Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Custom Painter slowing down initially #76859

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
@Dharanipalani

Description

@Dharanipalani

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;}

FLutter version details:
image

Metadata

Metadata

Assignees

No one assigned

    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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp