minikin / popover

Popover for Flutter. A popover is a transient view that appears above other content onscreen when you tap a control or in an area.
https://pub.dev/packages/popover
MIT License
166 stars 54 forks source link

[Bug]: Theme is not being captured before popover is pushed #86

Open Okizeme opened 7 months ago

Okizeme commented 7 months ago

Is there an existing issue for this?

Current Behavior

The bodyBuilder provides a context that is not inherited from the context parameter of the showPopover() function, resulting in Material's default colors being used instead of the app's theme colors.

Expected Behavior

As done in dialog.dart of Google's Material package, the theme from the context should be captured and passed to the RawDialogRoute.push() Exemple from the Material lib:

final CapturedThemes themes = InheritedTheme.capture(
    from: context,
    to: Navigator.of(
      context,
      rootNavigator: useRootNavigator,
    ).context,
  );

What operating system are you seeing the problem on?

macOS, iOS, Android, Windows

Relevant log output

No response

Anything else?

Work around would be to wrap the return of the bodyBuilder in a Theme widget using the previous context, like so:

showPopover(
      context: context,
      direction: PopoverDirection.bottom,
      arrowHeight: 8.0,
      arrowWidth: 16.0,
      radius: 12.0,
      width: 740.0,
      height: 400.0,
      bodyBuilder: (final ctx) {
        return Theme(
          data: context.theme,
          child: const MyWidgetInsidePopover(),
        );
      },
    );

Code of Conduct

minikin commented 6 months ago

@Okizeme, Thank you for the reporting. Feel free to create a PR to address the issue.