-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[web] Shadows on flutter_web not rendering like shadows in flutter #32215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web] Shadows on flutter_web not rendering like shadows in flutter #32215
Comments
I got also an issue when I add an Image widget (anywhere in the page). The shadow do not render blury gradient but (almost) solid lines. |
@yjbanov Thank you for working on this issue. |
Happy to find that this is an issue being worked on already. I was considering adding it otherwise. Just as info, the Flutter Community is looking forward to a resolution of this issue as well. It was e.g. recently mentioned in this tweet, here and here. Here is a link to a brief gist I made for the tweets, where it is demonstrated as well, but I think this issue has it all covered well enough. I just wanted to give my support and thumbs up 👍 for working on the issue! |
Update: as I was trying to understand how shadows worked in Flutter for mobile, I discovered an issue there too. My current plan is, instead of emulating what mobile does, I'll do something "reasonable". For example, we blur too aggressively, our HTML shadows do not match canvas shadows, they do not work on Safari canvas, and our bounds estimator does not match either (which is what I think causes the clipping). I'll fix these issues, but the shadows will still be a bit different from mobile. |
Thanks for looking into this issue and working on it. The things you found and mention in issue 51237 are indeed a bit different from this case. I have however seen the matter you mention in the new issue you made as well and will add some comments to it there. I think this issue should focus on getting shadows on HTML to look the same as they do on Android/iOS (and Desktop) given the same Flutter shadow or material elevation input. As far as I have seen given the same input the shadows and elevations on Android/iOS/Mac/Win are fairly close already, but web is totally different to the extent that it is broken, it looks totally wrong and cannot even be used as the look will deviate a lot from what was intended if designed on mobile/tablet/desktop. As for the issue in 51237 I think that is more a matter of how the imaginary light source that casts the elevation shadows is placed and that the current placement is not so suitable for larger surfaces. I will drop a comment on it there with some examples as well. |
Shadows are also incorrectly clipped in Chrome when using a custom ShapeBorder, which can be seen in #50508's example images. This is because clip-path clips the box shadow also, so you need to use CSS filter drop-shadows on the parent element (see https://css-tricks.com/using-box-shadows-and-clip-path-together/). |
Re-openened post-revert until re-land. /cc @yjbanov |
Wanted to add another simple example of this occurrence:
Code to reproduceimport 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Padding(
padding: const EdgeInsets.all(30.0),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(color: Colors.black, blurRadius: 12.0),
],
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(
'https://images.theconversation.com/files/93616/original/image-20150902-6700-t2axrz.jpg')))),
),
),
);
}
} |
Quick workaround - Add one more container on top and set it as transparent with your fixed size. This makes it draw the entire container therefore not clipping it's child container, so you can add padding to the child and make enough space for the shadows.
|
No the beta and stable channel haven't been updated in 2-3 months for some reason. @LucasAschenbach |
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 |
Describe the bug
Using this exact code on both web and mobile results in noticeably different rendered output.
I expect that the rendering of shadows should be consistent. The most noticeable difference can be noticed between the
BoxShadow
, butMaterial
with elevation seems to render differently as well. I use both as an example here.To Reproduce
Use the code above, and run on web and mobile. You should notice the same thing as in the images below
Expected behavior
Shadows should render similarly if not exactly the same.
Screenshots

On the left is Chrome, on the right an iOS emulator:
Desktop (please complete the following information):
macOS 10.14.4 (18E226)
Chrome Version 73.0.3683.103 (Official Build) (64-bit)
2.2.1 (build 2.2.1-dev.4.0 None)
ecbdadf118b497f41c4ed4599baa0cc1c1c0fc08
The text was updated successfully, but these errors were encountered: