auto static method

User auto({
  1. String? id,
  2. required String name,
  3. int? age,
  4. List<String>? tags,
  5. required Set<int> scores,
  6. Map<String, String>? metadata,
  7. Set<String>? tagsSet,
  8. Map<String, int>? stats,
})

Implementation

static User auto({
  String? id,
  required String name,
  int? age,
  List<String>? tags,
  required Set<int> scores,
  Map<String, String>? metadata,
  Set<String>? tagsSet,
  Map<String, int>? stats,
}) {
  final generatedId = id ?? const Uuid().v4();
  return User(
    id: generatedId,
    name: name,
    age: age ??
        18, // If you change the default, update the constructor default too
    tags: tags ??
        const [], // If you change the default, update the constructor default too
    scores: scores,
    metadata: metadata ??
        const {
          'role': 'user'
        }, // If you change the default, update the constructor default too
    tagsSet: tagsSet ??
        const {
          'a',
          'b'
        }, // If you change the default, update the constructor default too
    stats: stats ??
        const {
          'count': 1
        }, // If you change the default, update the constructor default too
  );
}