Open
Description
Steps to reproduce
Hello
- run example
- change the size to 100 or 200 or more, look at the raster thread
- this task is well solved by RepaintBoundary-CustomPainter, but maybe image.repeat has some problems, the performance problem can be aggravated if you add several similar objects, for example in gridView.
It's not correct to compare, but I did a similar task in Unity, and could make more than 50 similar objects, and the performance was excellent.
Expected results
good perfomance
Actual results
bad perfomance
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
showPerformanceOverlay: true,
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: const TiledTest(),
);
}
}
const int _kFilterImageSize = 64;
class TiledTest extends StatefulWidget {
const TiledTest({super.key});
@override
State<TiledTest> createState() => _TiledTestState();
}
class _TiledTestState extends State<TiledTest> {
int tileIndex = 0;
int size = 10;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Spacer(),
Expanded(
flex: 4,
child: Center(
child: AspectRatio(
aspectRatio: 1,
child: LayoutBuilder(
builder: (context, constraints) {
var scale =
(size * _kFilterImageSize) / constraints.maxWidth;
return Stack(
children: [
Image.asset('assets/images/kitty2.jpg'),
Image.asset(
'assets/tile/tile$tileIndex.png',
width: constraints.maxWidth,
height: constraints.maxHeight,
repeat: ImageRepeat.repeat,
alignment: Alignment.topLeft,
scale: scale,
),
],
);
},
),
),
),
),
Expanded(
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: FilledButton(
onPressed: () {
tileIndex = (tileIndex + 1) % 4;
setState(() {});
},
child: Text('Refresh'),
),
),
Expanded(
child: TextFormField(
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
decoration: InputDecoration(
labelText: 'Enter size',
border: OutlineInputBorder(),
),
onChanged: (value) {
if (value.isNotEmpty) {
size = int.tryParse(value)!;
setState(() {});
}
},
),
),
],
),
),
),
],
),
),
),
);
}
}
assets:
- assets/
- assets/images/
- assets/tile/
Screenshots or Video
Logs
Logs
-
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.32.2, on macOS 15.5 24F74 darwin-arm64, locale ru-RU) [642ms]
• Flutter version 3.32.2 on channel stable at /Users/denis/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 8defaa71a7 (4 days ago), 2025-06-04 11:02:51 -0700
• Engine revision 1091508939
• Dart version 3.8.1
• DevTools version 2.45.1
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3,1s]
• Android SDK at /Users/denis/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [2,0s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16E140
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [13ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) [13ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
[✓] VS Code (version 1.100.3) [11ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.112.0