Hi! First off, I love this package. It has solved so many problems for me.
My current use case is when a user signs in, I have their configuration for the app saved in Firebase. If it's their first time signing in, I have to populate it with reasonable empty fields. This is what that currently looks like:
// Configuration extends $Configuration and also uses json_serializable
//
// Inside document.get().then((snapshot) =>
final empty = Configuration.empty();
if (snapshot.exists) {
final configuration = Configuration.fromJson(snapshot.data);
await configurationDocument.setData(
Configuration(
primaryColor: configuration.primaryColor ?? empty.primaryColor,
// A lot more fields . . .
).toJson(),
);
} else {
await configurationDocument.setData(empty.toJson());
}
Hi! First off, I love this package. It has solved so many problems for me.
My current use case is when a user signs in, I have their configuration for the app saved in Firebase. If it's their first time signing in, I have to populate it with reasonable empty fields. This is what that currently looks like:
With merge I think could just say something like: