Commit 43b99cb7 authored by Administrator's avatar Administrator

factory needs it's own initializer

parent 6480ce2a
......@@ -43,14 +43,15 @@ class Athlete extends Model {
}
persist() async {
await Db().connect();
await DbAthlete(
await Db.create().connect();
var dbAthlete = DbAthlete(
firstName: firstName,
lastName: lastName,
stravaId: stravaId,
stravaUsername: stravaUsername,
photoPath: photoPath)
.save();
photoPath: photoPath);
int id = await dbAthlete.save();
print(id);
}
static Athlete of(BuildContext context) => ScopedModel.of<Athlete>(context);
......
......@@ -4,7 +4,9 @@ class Db {
static Db _dB;
static bool _isConnected = false;
factory Db() {
Db();
factory Db.create() {
if (_dB == null) _dB = Db();
return _dB;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment