auto static method
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,
})
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
);
}