You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
API docs for Container.color should have a "troubleshooting" section that talks about "mysterious dividers" #15035
I have ListView with simple rows that have one Text, and BoxDecoration with the background color. When in the middle of scrolling, I can see dividers between rows. Not exactly dividers, but I can see through the list (confirmed by setting different background color).
Tested on iOS simulator and Android device.
Flutter Doctor
[✓] Flutter (Channel master, v0.1.6-pre.7, on Mac OS X 10.12.6 16G1212, locale en-US)
• Flutter version 0.1.6-pre.7 at /Users/jokr/Documents/flutter/flutter
• Framework revision c3bbcb6f91 (5 days ago), 2018-02-24 09:28:58 -0800
• Engine revision ead227f118
• Dart version 2.0.0-dev.28.0.flutter-0b4f01f759
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.1)
• Android SDK at /Users/jokr/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.2, Build version 9C40b
• ios-deploy 1.9.2
• CocoaPods version 1.3.1
[✓] Android Studio (version 3.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] IntelliJ IDEA Community Edition (version 2017.2.5)
• Flutter plugin version 21.2.2
• Dart plugin version 172.4343.25
That is the normal case. But when scrolling I get this:
@Hixie suggests setting the background colour for the entire Drawer to the colour you're using for the list tiles. It's likely this is a result of sub-pixel anti-aliasing.
I was able to reproduce this bug with very simple example:
var putThisIntoScaffoldBody =newListView.builder(itemBuilder: (BuildContext context, int index) {
returnnewContainer(
decoration:newBoxDecoration(color:Colors.black),
height:30.0,
);
}, itemCount:30,
);
Just put this widget into Scaffold body. On iOS I can see it when bouncing with the scroll. On Android, it's much easier to see it, you don't even need to scroll:
You can also see that not every divider is same width.
@itsJoKr Yeah, that most recent screenshot shows that this is indeed what we suspected. You're drawing a series of rectangles adjacent to each other, on top of a different background color, but they don't quite line up with the physical pixel boundaries. This means we try to antialias the edges, and each one is painted on top of the background, so the background shows up in the antialiasing. This is working as intended; it's how graphics works.
There's two basic ways to avoid this problem. The first is to do as suggested above -- if you want two adjacent boxes to have the same background and be adjacent, then draw the background once, e.g. by putting them into a single box with that background. The second is to wrap all those widgets with a RepaintBoundary, which will cause them to all be painted as one graphic which is then anti-aliased once with the parent. That might not solve the issue, depending on exactly what the alignment ends up being, but it should be better.
In general though the right answer is the first suggestion here; don't put two adjacent boxes with the same background color, just put the background color on the common background.
We should document this somewhere with diagrams to explain it better. Not sure where, maybe on Container.color?
Reacted by Josip Krnjic, Simon Lightfoot, Boehrsi, droplet, Jerry Zhou, MarkXiu, Pedro Massango, Dominik Roszkowski, Bartek Pacia and Shannon Chen
changed the title [-]ListView shows dividers when scrolling[/-][+]API docs for Container.color should have a "troubleshooting" section that talks about "mysterious dividers"[/+]on Mar 2, 2018
"In general though the right answer is the first suggestion here; don't put two adjacent boxes with the same background color, just put the background color on the common background."
Is this always a viable solution? For example, I want my appBar to have the same background color as the first widget in the body of a Scaffold, but the rest needs to be a white BG.
I've also fixed this by moving from a bottom padding of 5.0 to a SizedBox of 5.0 and it "Fixed" the problem, but felt a bit weird. The solution you propose sounds like creating a Stack with a Container + BG for the top part and a Scaffold for the rest.
Would be cool if padding "Just Worked" for this use case
My problem here is the line: "This is working as intended; it's how graphics works." Because I'm pretty sure I wouldn't see this issue in Android and iOS native.
Reacted by Brian Egan, afedorychak, Simon Lightfoot, Fogel Artem, Jacky Chan, Pho Tran, Josip Krnjic, Omi231, Tommi Nikkanen, Lucas Antunes and 3 more
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
cbracken commentedon Mar 1, 2018
/cc @Hixie @HansMuller for their thoughts
HansMuller commentedon Mar 1, 2018
That's pretty strange: it's wrong but it looks sort-of attractive. Could you provide a small example that demos the problem?
cbracken commentedon Mar 2, 2018
@Hixie suggests setting the background colour for the entire Drawer to the colour you're using for the list tiles. It's likely this is a result of sub-pixel anti-aliasing.
itsJoKr commentedon Mar 2, 2018
@cbracken Yes, setting the background of the entire drawer "visually" fixes the issue, but there is still the issue.
@HansMuller Doesn't matter if it looks better. I didn't write anything in the code that should display dividers, and that's why this is the issue.
itsJoKr commentedon Mar 2, 2018
I was able to reproduce this bug with very simple example:
Just put this widget into Scaffold body. On iOS I can see it when bouncing with the scroll. On Android, it's much easier to see it, you don't even need to scroll:
You can also see that not every divider is same width.
HansMuller commentedon Mar 2, 2018
Understood. That was just my attempt at humor.
Hixie commentedon Mar 2, 2018
@itsJoKr Yeah, that most recent screenshot shows that this is indeed what we suspected. You're drawing a series of rectangles adjacent to each other, on top of a different background color, but they don't quite line up with the physical pixel boundaries. This means we try to antialias the edges, and each one is painted on top of the background, so the background shows up in the antialiasing. This is working as intended; it's how graphics works.
There's two basic ways to avoid this problem. The first is to do as suggested above -- if you want two adjacent boxes to have the same background and be adjacent, then draw the background once, e.g. by putting them into a single box with that background. The second is to wrap all those widgets with a RepaintBoundary, which will cause them to all be painted as one graphic which is then anti-aliased once with the parent. That might not solve the issue, depending on exactly what the alignment ends up being, but it should be better.
In general though the right answer is the first suggestion here; don't put two adjacent boxes with the same background color, just put the background color on the common background.
We should document this somewhere with diagrams to explain it better. Not sure where, maybe on
Container.color?itsJoKr commentedon Mar 2, 2018
OK, I understand it now, thanks for the explanation.
[-]ListView shows dividers when scrolling[/-][+]API docs for Container.color should have a "troubleshooting" section that talks about "mysterious dividers"[/+]brianegan commentedon Mar 15, 2018
"In general though the right answer is the first suggestion here; don't put two adjacent boxes with the same background color, just put the background color on the common background."
Is this always a viable solution? For example, I want my
appBarto have the same background color as the first widget in thebodyof a Scaffold, but the rest needs to be a white BG.I've also fixed this by moving from a bottom padding of 5.0 to a SizedBox of 5.0 and it "Fixed" the problem, but felt a bit weird. The solution you propose sounds like creating a
Stackwith a Container + BG for the top part and a Scaffold for the rest.Would be cool if padding "Just Worked" for this use case
itsJoKr commentedon Mar 15, 2018
My problem here is the line: "This is working as intended; it's how graphics works." Because I'm pretty sure I wouldn't see this issue in Android and iOS native.
SteveAlexander commentedon Sep 4, 2018
For a specific artistic layout I was having this "mystery thin divider" problems with, I wrote the following:
Using whole multiples of the
quantizedUnit, and filling in with theremainder, I was able to make my Mondriaan-esque layout work seamlessly.Hixie commentedon Sep 17, 2018
See also #17084
goderbauer commentedon Dec 28, 2018
Closing this as dupe of #17084.
github-actions commentedon Aug 15, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.