Fix mod instance being the same only on deserialize
This commit is contained in:
parent
129e69f2e0
commit
f15a1f4fbc
2 changed files with 10 additions and 3 deletions
|
@ -152,7 +152,7 @@ class ModManagerState extends State<ModManager> {
|
||||||
itemBuilder: (ctx, idx) {
|
itemBuilder: (ctx, idx) {
|
||||||
Mod mod = settings.mods[idx];
|
Mod mod = settings.mods[idx];
|
||||||
return Padding(
|
return Padding(
|
||||||
key: Key("${mod.mod_instance_id}"),
|
key: Key("${mod.mod_instance_id()}"),
|
||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text(mod.mod_name),
|
title: Text(mod.mod_name),
|
||||||
|
@ -222,7 +222,7 @@ class ModPage extends StatelessWidget {
|
||||||
id.text = args.mod_id.toString();
|
id.text = args.mod_id.toString();
|
||||||
name.text = args.mod_name;
|
name.text = args.mod_name;
|
||||||
isNewMod = args.newMod;
|
isNewMod = args.newMod;
|
||||||
instance = args.mod_instance_id;
|
instance = args.mod_instance_id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,14 @@ class Mod {
|
||||||
int mod_id;
|
int mod_id;
|
||||||
|
|
||||||
bool newMod = false;
|
bool newMod = false;
|
||||||
final mod_instance_id = UuidV4().generate();
|
String _id = "";
|
||||||
|
String mod_instance_id() {
|
||||||
|
if (_id.isEmpty) {
|
||||||
|
_id = UuidV4().generate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
Mod({this.mod_name = "undef", this.mod_id = 0, this.newMod = false});
|
Mod({this.mod_name = "undef", this.mod_id = 0, this.newMod = false});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue