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

copyWith for all data types #459

Open
martin-braun opened this issue May 26, 2024 · 0 comments
Open

copyWith for all data types #459

martin-braun opened this issue May 26, 2024 · 0 comments

Comments

@martin-braun
Copy link

martin-braun commented May 26, 2024

So I come to the realization that especially on Cupertino widgets not all styles are manageable through CupertinoThemeData, thus I end up having to set a cupertino theme builder on most widgets to do some extensive designing.

In order to ensure a coherent theme across all widgets, I define my builder functions in a style.dart. Now, what if I have special rules only for one widget? I would love to run my style builder function from my style.dart, but still apply more values to it to make the rules special using a copyWith, but there is none.

Example:

style.dart

CupertinoListTileData styleOverviewListTileCupertino(
    BuildContext context, PlatformTarget _) {
  final ThemeData theme = Theme.of(context);
  return CupertinoListTileData(
    backgroundColorActivated: theme.colorScheme.primary,
  );
}

my-widget.dart

// ...
          PlatformListTile(
              cupertino: (context, target) {
                return styleOverviewListTileCupertino(context, target).copyWith(
                    trailing: const Icon(Icons.chevron_right)
                );
              },
// ...

Here, copyWith doesn't exist. I think we should change that.

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

No branches or pull requests

1 participant