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.57k stars 171 forks source link

`copyWith` for all data types #459

Open martin-braun opened 3 months ago

martin-braun commented 3 months ago

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.