flash icon indicating copy to clipboard operation
flash copied to clipboard

Bug: showing flashbar at `Position.top` changes the `systemNavigationBarColor` to black

Open tmaihoff opened this issue 1 year ago • 5 comments

Here is the minimal reproducible example.

So when you first set the systemNavigationBarColor like so:

    SystemChrome.setSystemUIOverlayStyle(
      const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        systemNavigationBarColor: Colors.green,
        systemNavigationBarContrastEnforced: false,
      ),
    );
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
      SystemUiOverlay.bottom,
    ]);

and then call context.showFlash with FlashPosition.top, the green system navigation bar changes from green back to black.

This is clearly unwanted as the systemNavigationBarColor is normally set once and supposed to keep its value.

I have tracked down the issue to the following part in the flash code:

    // flash.dart:583
    if (widget.position == FlashPosition.top) {
      final brightness = ThemeData.estimateBrightnessForColor(backgroundColor);
      child = AnnotatedRegion<SystemUiOverlayStyle>(
        value: brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
        child: child,
      );
    }

I deleted this if statement which makes it work. However, I don't know if that has any implications that I'm not aware of. For me it fixes the issue.

I have opened a PR and looking forward to your comments about if this statement is necessary or can safely be removed.

tmaihoff avatar Sep 01 '24 09:09 tmaihoff

As a workaround, you can set the surfaceTintColor property to white in the FlashBar widget.

Ludo978 avatar Sep 17 '24 23:09 Ludo978

As a workaround, you can set the surfaceTintColor property to white in the FlashBar widget.

That does not solve the issue. The color should not be set explicitly, as we would then have to handle light and dark mode changes etc.

@sososdk any plans to review this? The PR is ready for 4 months.

tmaihoff avatar Dec 22 '24 13:12 tmaihoff

@tmaihoff
Thank you for the fix! This is exactly what we needed.

@sososdk
I’d really appreciate it if you could review this PR. Thank you for providing such a helpful library and for your support in advance.

honishi avatar Jan 13 '25 06:01 honishi

Any updates on this, I am encountering same situation ?

Abdurahmon727 avatar Jan 29 '25 04:01 Abdurahmon727

@sososdk is this package abandoned?

tmaihoff avatar Jul 23 '25 12:07 tmaihoff