Repository navigation
Antialiasing behaviour when same-colour #14288
Copy link
Copy link
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: gamedevIssues related to game development with FlutterIssues related to game development with Flutterc: renderingUI glitches reported at the engine/skia or impeller rendering levelUI glitches reported at the engine/skia or impeller rendering levelcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.engineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Description
Latest status update: #14288 (comment); some work around suggestions: #14288 (comment)
Steps to Reproduce
Following source code:
import 'package:flutter/material.dart';
const Color color = const Color.fromARGB(255, 100, 100, 100);
void main() =>
runApp(
new Container(
color: const Color.fromARGB(255, 0, 0, 0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
textDirection: TextDirection.ltr,
children: [
new Expanded(
child: new Container(
color: color,
),
),
new Expanded(
child: new Container(
color: color,
),
),
new Expanded(
child: new Container(
color: color,
),
),
new Expanded(
child: new Container(
color: color,
),
),
new Expanded(
child: new Container(
color: color,
),
),
new Expanded(
child: new Container(
color: color,
),
),
new Expanded(
child: new Container(
color: color,
),
),
],
),
),
);produces following result:
Looks like background of the container is popping out and we see vertical lines. That should not be the case as all children of the row are Expanded and thus should fill the whole area.
If we remove one child lines are gone.
Logs
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
Built build/app/outputs/apk/app-debug.apk (22.4MB).
I/FlutterActivityDelegate( 8398): onResume setting current activity to this
D/EGL_emulation( 8398): eglMakeCurrent: 0xaad2c640: ver 3 1 (tinfo 0xa057c5b0)
E/eglCodecCommon( 8398): glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon( 8398): glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon( 8398): glUtilsParamSize: unknow param 0x00008cdf
E/eglCodecCommon( 8398): glUtilsParamSize: unknow param 0x00008cdf
E/eglCodecCommon( 8398): glUtilsParamSize: unknow param 0x00008824
E/eglCodecCommon( 8398): glUtilsParamSize: unknow param 0x00008824
D/ ( 8398): HostConnection::get() New Host Connection established 0xa31a3640, tid 8416
D/EGL_emulation( 8398): eglMakeCurrent: 0xaad2c640: ver 3 1 (tinfo 0xa3183790)
D/EGL_emulation( 8398): eglMakeCurrent: 0xaad2c760: ver 3 1 (tinfo 0xa057cc10)
Syncing files to device Android SDK built for x86...
Flutter Doctor
[✓] Flutter (on Linux, locale en_US.UTF-8, channel master)
• Flutter version unknown at <path_to_flutter>
• Framework revision 5ae770345a (3 days ago), 2018-01-23 13:46:14 -0800
• Engine revision 171d032f86
• Tools Dart version 2.0.0-dev.16.0
• Engine Dart version 2.0.0-edge.93d8c9fe2a2c22dc95ec85866af108cfab71ad06
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at <path_to_android>
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• ANDROID_HOME = <path_to_android>
• Java binary at: <path_to_android-studio>/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[✓] Android Studio (version 3.0)
• Android Studio at <path_to_android-studio>
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[✓] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: gamedevIssues related to game development with FlutterIssues related to game development with Flutterc: renderingUI glitches reported at the engine/skia or impeller rendering levelUI glitches reported at the engine/skia or impeller rendering levelcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.engineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue

Activity
radzish commentedon Jan 26, 2018
Another example (I believe it is somehow related: )
We should not see border here. If widht/height are changed to 150.0, square is gone.
Hixie commentedon Jan 29, 2018
This is normal behaviour. What's happening is that the boxes are not quite aligned with pixel boundaries, so there's some anti-aliasing happening on the boundaries, which involves transparency, which means that for those pixels the two grays are overlapping and looking darker.
As a general rule when doing anti-aliasing you want to avoid putting identically-coloured boxes adjacent or over each other unless you can guarantee physical pixel alignment.
Alternatively, you can use
saveLayer(orRepaintBoundary) to cause a bunch of paint operations to get merged into one and composited as one. Not sure that that would help in these cases specifically but it is a tool that can be useful in this kind of situation.radzish commentedon Jan 30, 2018
This is not boxes overlapping, but rather spare space between boxes, so color of background is popping up. I was changing background to different color and this color was popping out.
radzish commentedon Feb 22, 2018
Root cause is that boxes can not be aligned with physical pixels. I would not call it "normal", I would rather call it "expected".
On android similar (semantically) case is handled properly:
So I think flutter should improve in this case.
The only workaround I found for me at the moment is sizing children manually like this:
[-]Expanded elements not taking the whole are of their parent[/-][+]Expanded elements not taking the whole area of their parent[/+][-]Expanded elements not taking the whole area of their parent[/-][+]Document the issue of antialiasing when same-colour blocks abut, and some workarounds[/+][-]Document the issue of antialiasing when same-colour blocks abut, and some workarounds[/-][+]Document the issue of antialiasing when same-colour blocks abut, and some workarounds (API docs, FAQ)[/+]zoechi commentedon Dec 17, 2018
There are also
130 remaining items
Amir-P commentedon Jun 12, 2024
Just wanted to share another case with you (#150035). It happens with Impeller on iOS too.
ulisseshen commentedon Jul 14, 2024
Is it a skia or a Flutter issue?
LvtLvt commentedon Jul 18, 2024
thanks to you, I was able to easily solve the problem without much overhead. thank you so much
officialismailshah commentedon Jul 28, 2024
https://stackoverflow.com/questions/74292370/getting-rid-of-small-line-in-between-2-containers-flutter-dart
this stack Overflow answered worked for me
devnta commentedon Oct 15, 2024
Unbelievable, this issue has existed for a few years?
Any official solution on this?
spydon commentedon Oct 21, 2024
This issue can be very apparent when you're making games with Flutter (and Flame), and the curious thing is that nowadays the issue is usually worse with Impeller than it is with Skia.

Mik77o commentedon Nov 21, 2024
The same issue is noticed on Flutter Web (3.24.4) for
ListView(mostly while scrolling).NashIlli commentedon Feb 12, 2025
+1
ThomasDevApps commentedon Mar 9, 2025
I have the same problem using
SliverAppBar(I can give the code to reproduce the problem if needed).davidhicks980 commentedon May 16, 2025
There are a lot of comments here so I apologize if I'm duplicating another solution. Also, this won't fix the problem for everyone.
There is the option of disabling anti-aliasing:
AliasedBoxDecoration
Using this solution fixes the original problem. I'm not sure about others.
zhujunjieyuewen commentedon Jun 18, 2025
On my Pixel 9 Pro device (with a devicePixelRatio of 2.25), setting the ListView item height to 200.0 results in no gaps appearing between items during scrolling. However, setting the height to 210.0 causes noticeable gaps to appear between items during scrolling.
After reading the previous comments, I understand the cause of this phenomenon: 200 * 2.25 = 450 (an integer number of physical pixels), while 210 * 2.25 = 472.5 (a non-integer number of physical pixels).
As a framework user, however, I don't believe this is something I should need to be concerned about. What I expect is the ability to freely set the item height to any desired value, and for the framework to automatically handle the issue where that height translates to a non-integer number of physical pixels. Whether the framework rounds down (floor), rounds up (ceil), or uses any other appropriate conversion method is acceptable to me—as long as the outcome ensures there are no gaps between items.
After all, the page I'm currently working on is a comic reader page. Seeing gaps appear between visually continuous images is genuinely disruptive to the reading experience.
Here is my demo code:
The resulting behavior:
41fb3ddf502ef46201437cdb54ddea38.mp4
The appearance issue on the comic reader page matches the screenshot shown in a previous comment #14288 (comment).
orestesgaolin commentedon Jul 17, 2025
I'm having the same issue now when implementing a HR chart using CustomPaint. Putting two paths with the same color back to back where right x coordinate coincides with left x coordinate results with quite ugly look.
Having to figure out how to snap path to physical pixels in such case is huge annoyance for a developer.
Edit
I was able to workaround this issue with following (inspired by package:pixel_snap)
AwaisQazii commentedon Oct 29, 2025
My workaround on this issue is: #97054 (comment)
I was able to resolve this issue by setting:
resizeToAvoidBottomInset: false,
and add padding to singlechildscrollview
SingleChildScrollView(
padding: EdgeInsets.only(
bottom: MediaQuery.viewInsetsOf(context).bottom + 50,
),
then adding scrollPadding to the TextField:
scrollPadding: EdgeInsets.only(
bottom: MediaQuery.viewInsetsOf(context).bottom + 50,
),
For context, my layout structure looks like this:
Container
└─ background color: red
└─ Scaffold
├─ backgroundColor: transparent
├─ resizeToAvoidBottomInset: false
└─ body:
└─Single ChildScrollView
padding: EdgeInsets.only(
bottom: MediaQuery.viewInsetsOf(context).bottom + 50,
),
└─ TextField
└─ scrollPadding:
EdgeInsets.only(
bottom: MediaQuery.viewInsetsOf(context).bottom + 50,
)
aidarbye commentedon Dec 9, 2025
lifelikejuly commentedon Jan 30, 2026