extra form validation and connection list done
This commit is contained in:
parent
bd8884787d
commit
789cea13a1
5 changed files with 281 additions and 74 deletions
44
lib/connection.dart
Normal file
44
lib/connection.dart
Normal file
|
@ -0,0 +1,44 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class Connection {
|
||||
String? host;
|
||||
int? port;
|
||||
String? username;
|
||||
String? privateKey;
|
||||
String? password;
|
||||
bool? isEncryptionEnabled;
|
||||
bool? isDefault;
|
||||
|
||||
Connection() : isEncryptionEnabled = true, isDefault = false;
|
||||
|
||||
Connection.fromJson(Map<String, dynamic> json) {
|
||||
host = json['host'];
|
||||
port = json['port'];
|
||||
username = json['username'];
|
||||
privateKey = json['privateKeyFilePath'];
|
||||
password = json['password'];
|
||||
isEncryptionEnabled = json['isEncryptionEnabled'];
|
||||
isDefault = json['isDefault'];
|
||||
}
|
||||
|
||||
String get toJson => jsonEncode({
|
||||
'host': host,
|
||||
'port': port,
|
||||
'username': username,
|
||||
'privateKeyFilePath': privateKey,
|
||||
'password': password,
|
||||
'isEncryptionEnabled': isEncryptionEnabled,
|
||||
'isDefault': isDefault
|
||||
});
|
||||
|
||||
|
||||
bool assertComplete() {
|
||||
assert(host != null);
|
||||
assert(port != null);
|
||||
assert(username != null);
|
||||
assert(privateKey != null || password != null);
|
||||
assert(isEncryptionEnabled != null);
|
||||
assert(isDefault != null);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue