duyduong / flutter_native_admob

Plugin to integrate native firebase admob to Flutter application
MIT License
62 stars 85 forks source link

NativeAdmobOptions not changing colors on app theme change #76

Open naamapps opened 3 years ago

naamapps commented 3 years ago

Hey, I have a dark theme and a light theme in my app. When initializing the app with the dark theme, all of the ads have a white text color. When changing the theme to light, the text color of the ads remain white so its not visible (white text on white background).

Here is the code:

options: NativeAdmobOptions(
  adLabelTextStyle: NativeTextStyle(
    backgroundColor: Theme.of(context)
        .colorScheme
        .secondaryVariant,
  ),
  callToActionStyle: NativeTextStyle(
    backgroundColor: Theme.of(context).primaryColor,
    color: Colors.white,
  ),
  headlineTextStyle: NativeTextStyle(
    color:
        Theme.of(context).colorScheme.onBackground, // This is white in dark theme, and black in light theme
  ),
),

I think you should check inside the widget if any of the options are changed and rebuild the ad if it's possible.

Thanks

bdlukaa commented 3 years ago

I had the same problem. You need to rebuild the widget manually (remove from the tree and add it again) and reload the ad

naamapps commented 3 years ago

@bdlukaa Thanks for your reply, Do you have an example of how to achieve this (removing a widget from the tree when changing a theme)? It would be very helpful