stryder-dev / flutter_platform_widgets

Target the specific design of Material for Android and Cupertino for iOS widgets through a common set of Platform aware widgets
MIT License
1.58k stars 171 forks source link

Unable to change the back button on appbar in iOS, works on Android #382

Closed MxD-js closed 1 year ago

MxD-js commented 1 year ago

Hi,

I've looked through the Wiki and open/closed issues and cannot find an answer.

In light mode, I see the back button, works as expected.

image

However in dark mode, the back button is the same color as the background, if you tap it the page pops off the stack as expected.

image

If I set the barBackgroundColor color to Colors.white, the back button shows up.

image

Question is how can I change the color to the back button? I've tried adding primaryColor to the ThemeData but no dice. Same result.

I copied the dark/light mode code from the Wiki.


  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
// Your default app's theme mode selection which can be changed.
    // const themeMode = ThemeMode.system;

    final lightTheme = ThemeData.light();
    final darkTheme = ThemeData.dark();

    final cupertinoLightTheme =
        MaterialBasedCupertinoThemeData(materialTheme: lightTheme);

    const darkDefaultCupertinoTheme =
        CupertinoThemeData(brightness: Brightness.dark);

    final cupertinoDarkTheme = MaterialBasedCupertinoThemeData(
      materialTheme: darkTheme.copyWith(
        cupertinoOverrideTheme: CupertinoThemeData(
          brightness: Brightness.dark,
          barBackgroundColor: darkDefaultCupertinoTheme.barBackgroundColor,
          textTheme: CupertinoTextThemeData(
            navActionTextStyle: darkDefaultCupertinoTheme
                .textTheme.navActionTextStyle
                .copyWith(color: darkTheme.primaryColor),
            navLargeTitleTextStyle: darkDefaultCupertinoTheme
                .textTheme.navLargeTitleTextStyle
                .copyWith(color: const Color(0xF0F9F9F9)),
          ),
        ),
      ),
    );
MxD-js commented 1 year ago

Fixed it.

commented all this code out from the example docs.


    // final cupertinoDarkTheme = MaterialBasedCupertinoThemeData(
    //   materialTheme: darkTheme.copyWith(
    //     appBarTheme:
    //         const AppBarTheme(iconTheme: IconThemeData(color: Colors.white)),
    //     cupertinoOverrideTheme: CupertinoThemeData(
    //       brightness: Brightness.dark,
    //       barBackgroundColor: darkDefaultCupertinoTheme.barBackgroundColor,
    //       textTheme: CupertinoTextThemeData(
    //         navActionTextStyle: darkDefaultCupertinoTheme
    //             .textTheme.navActionTextStyle
    //             .copyWith(color: darkTheme.primaryColor),
    //         navLargeTitleTextStyle: darkDefaultCupertinoTheme
    //             .textTheme.navLargeTitleTextStyle
    //             .copyWith(color: const Color(0xF0F9F9F9)),
    //       ),
    //     ),
    //     colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.white),
    //   ),
    // );

and simply using

  const darkDefaultCupertinoTheme =
        CupertinoThemeData(brightness: Brightness.dark);

as the dark theme for cupertino.