2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05:29 +00:00

Fixes for type casting

This commit is contained in:
Oliver
2021-09-28 17:53:14 +10:00
parent 9d95cae612
commit c1152ee286
18 changed files with 294 additions and 228 deletions

View File

@ -38,10 +38,10 @@ class UserProfile {
factory UserProfile.fromJson(int key, Map<String, dynamic> json, bool isSelected) => UserProfile(
key: key,
name: json['name'],
server: json['server'],
username: json['username'],
password: json['password'],
name: json['name'] as String,
server: json['server'] as String,
username: json['username'] as String,
password: json['password'] as String,
selected: isSelected,
);
@ -73,7 +73,7 @@ class UserProfileDBManager {
return profiles.length > 0;
}
Future addProfile(UserProfile profile) async {
Future<void> addProfile(UserProfile profile) async {
// Check if a profile already exists with the name
final bool exists = await profileNameExists(profile.name);
@ -83,7 +83,7 @@ class UserProfileDBManager {
return;
}
int key = await store.add(await _db, profile.toJson());
int key = await store.add(await _db, profile.toJson()) as int;
print("Added user profile <${key}> - '${profile.name}'");
@ -91,7 +91,7 @@ class UserProfileDBManager {
profile.key = key;
}
Future selectProfile(int key) async {
Future<void> selectProfile(int key) async {
/*
* Mark the particular profile as selected
*/
@ -101,7 +101,7 @@ class UserProfileDBManager {
return result;
}
Future updateProfile(UserProfile profile) async {
Future<void> updateProfile(UserProfile profile) async {
if (profile.key == null) {
await addProfile(profile);
@ -115,7 +115,7 @@ class UserProfileDBManager {
return result;
}
Future deleteProfile(UserProfile profile) async {
Future<void> deleteProfile(UserProfile profile) async {
await store.record(profile.key).delete(await _db);
print("Deleted user profile <${profile.key}> - '${profile.name}'");
}
@ -135,8 +135,8 @@ class UserProfileDBManager {
if (profiles[idx].key is int && profiles[idx].key == selected) {
return UserProfile.fromJson(
profiles[idx].key,
profiles[idx].value,
profiles[idx].key as int,
profiles[idx].value as Map<String, dynamic>,
profiles[idx].key == selected,
);
}
@ -161,8 +161,8 @@ class UserProfileDBManager {
if (profiles[idx].key is int) {
profileList.add(
UserProfile.fromJson(
profiles[idx].key,
profiles[idx].value,
profiles[idx].key as int,
profiles[idx].value as Map<String, dynamic>,
profiles[idx].key == selected,
));
}