Skip to content
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

feat: added frontLayerBoxShadow option to BackdropScaffold #113

Closed
wants to merge 9 commits into from
Closed

feat: added frontLayerBoxShadow option to BackdropScaffold #113

wants to merge 9 commits into from

Conversation

lastmeta
Copy link

@lastmeta lastmeta commented Jan 4, 2022

see #112
I learned that the shadow was inverted since the front layer is within a Material widget. So in this feature we wrap the material widget in a Container with the given BoxShadow list. If no box shadow is provided, it works the same as before.

manually tested.

With this we can easily specify a drop shadow to be cast on the app bar and back layer.

@lastmeta lastmeta changed the title added a shadow to the front layer A new feature: added a shadow to the front layer Jan 4, 2022
@lastmeta lastmeta changed the title A new feature: added a shadow to the front layer feat: added a shadow to the front layer Jan 4, 2022
lib/src/scaffold.dart Outdated Show resolved Hide resolved
@daadu daadu changed the title feat: added a shadow to the front layer feat: added frontLayerBoxShadow option to BackdropScaffold Jan 5, 2022
lib/src/scaffold.dart Outdated Show resolved Hide resolved
@daadu daadu requested a review from WieFel January 5, 2022 06:10
@daadu daadu linked an issue Jan 5, 2022 that may be closed by this pull request
lib/src/scaffold.dart Outdated Show resolved Hide resolved
lastmeta and others added 4 commits January 5, 2022 08:57
Co-authored-by: Harsh Bhikadia <harsh.bhikadiya@gmail.com>
Co-authored-by: Harsh Bhikadia <harsh.bhikadiya@gmail.com>
@lastmeta
Copy link
Author

lastmeta commented Jan 5, 2022

updated code with all suggestions, I guess this feature should be mentioned in the docs, unless those are generated automatically...

@lastmeta
Copy link
Author

lastmeta commented Jan 5, 2022

by the way, I added this in during the constructor:

    assert(frontLayerBoxShadow == null || frontLayerBoxShadow!.isNotEmpty),

because this is your guy's project but I just gotta mention I disagree with the premise. This means the user cannot specify an empty list. but why not? Perhaps the shadow is variable dependent and therefore could result in an empty list during runtime. With this check the user must handle the empty list case and explicitly convert it to null.

Why is that more beneficial? Shouldn't the acceptance of the variable be as robust as possible to make things as easy as possible on the user of the library?

I'm just a mid level programmer so perhaps there's a best practice principle I'm missing out on here. But I figure if it adds no complexity why not make it robust?

@WieFel
Copy link
Collaborator

WieFel commented Jan 6, 2022

@lastmeta valid point.
I think the frontLayerBoxShadow!.isNotEmpty was only taken over into the constructor because you previously had it inside the if-clause.

Probably it would suffice to only add assert(frontLayerBoxShadow == null) to the constructor. If the user sets a box shadow with an empty list, the front layer would be wrapped with the box shadow which wouldn't cause any UI change, right? Or does BoxShadow throw an error if the list is empty?

@lastmeta
Copy link
Author

lastmeta commented Jan 6, 2022

Or does BoxShadow throw an error if the list is empty?

it does not, so that would work, is that a change you'd like to see?

@daadu
Copy link
Member

daadu commented Jan 9, 2022

@lastmeta I just checked the code for BoxDecoration in flutter, it handles the null and empty case by it self. Therefore this checks on our end are unnecessary. I assumed you added this checks before BoxDecoration would not handle it.

Therefore, I would now suggest removing this checks - both from constructor and in _buildFrontPanel

lib/src/scaffold.dart Outdated Show resolved Hide resolved
@@ -572,6 +579,11 @@ class BackdropScaffoldState extends State<BackdropScaffold>
),
),
);
if (widget.frontLayerBoxShadow == null) return frontPanel;
return Container(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just warp this around the Material without any checks

Co-authored-by: Harsh Bhikadia <harsh.bhikadiya@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a shadow to the front layer
3 participants