data_class icon indicating copy to clipboard operation
data_class copied to clipboard

feat: simpler `copyWith` syntax

Open felangel opened this issue 9 months ago • 11 comments

Description

It'd be nice to revert back to the original copyWith API (no lambdas) but be able to maintain the ability to copyWith null values.

Desired API

@Data()
class Person {
  final String name;
  final String? nickname;
}

void main() {
  const dash = Person(name: 'Dash', nickname: 'Dashy');
  print(dash.copyWith()); // Person(name: Dash, nickname: Dashy)
  print(dash.copyWith(name: 'Sparky')); // Person(name: Sparky, nickname: Dashy)
  print(dash.copyWith(nickname: null)); // Person(name: Dash, nickname: null)
}

Additional Context

https://github.com/felangel/data_class/issues/3#issuecomment-2117557442

felangel avatar May 17 '24 14:05 felangel