Skip to content
Snippets Groups Projects
Commit 2b55b2d5 authored by Maximilian Betz's avatar Maximilian Betz
Browse files

loading from shared preferences not yet working

parent 12c9686f
No related branches found
No related tags found
1 merge request!1Devices also Contact Based
......@@ -186,6 +186,9 @@ class _MyHomePageState extends State<Configuration> {
}else{
await configuration.storeToSharedPrefs();
// collection has not been changed but store the other parameters
statusPopUpMessageText = 'Stored changed configuration.';
popUpError = false;
......@@ -198,12 +201,6 @@ class _MyHomePageState extends State<Configuration> {
statusPopUpMessageText = errorText.substring(10, errorText.length); //Remove 'Exception' from string.
popUpError = true;
//_showResultPopup(context,
// errorText,
// true
//);
//setState(() {});
}
setState(() {_showResultPopup(context, statusPopUpMessageText, popUpError);});
}
......@@ -355,7 +352,7 @@ class _MyHomePageState extends State<Configuration> {
const SizedBox(height: 15.0),
TextFormField(
keyboardType: TextInputType.text,
keyboardType: TextInputType.url,
autofocus: false,
initialValue: configuration.restRequestUrl,
decoration: const InputDecoration(
......
......@@ -340,7 +340,14 @@ abstract class ConfigurationStoreBase {
eventTypes.add(EventType.fromJson(element));
}
//TODO: fix this here! What is the problem.
print(map['labelConfiguration']);
labelConfig = LabelConfiguration.fromJson(map['labelConfiguration']);
print(map['labelConfiguration']);
print(map['restRequestUrl']);
restRequestUrl = map['restRequestUrl'];
initialized = map['initialized'];
......@@ -405,8 +412,9 @@ class ConfigurationStoreInstance extends ConfigurationStoreBase {
final prefs = await SharedPreferences.getInstance();
prefs.setString('configuration', jsonEncode(toMap()));
debugPrint('Stored current configuration to shared prefs');
debugPrint('${toMap()['labelConfiguration']}');
debugPrint('${toMap()['restRequestUrl']}');
}
Future<void> loadFromSharedPrefs() async {
......@@ -423,7 +431,7 @@ class ConfigurationStoreInstance extends ConfigurationStoreBase {
final prefs = await SharedPreferences.getInstance();
final String? configuration = prefs.getString('configuration');
if (configuration != null){
debugPrint('Configuration String: ' + configuration);
debugPrint('Configuration String: $configuration');
fromMap(jsonDecode(configuration));
debugPrint('Configuration loaded from shared preferences');
}else{
......
......@@ -56,7 +56,7 @@ class SensorConnector {
List<Collection> collectionList = [];
try{
final response = await http.get(Uri.parse(url)).timeout(Duration(seconds: 3)); //TODO: check if this timeout works
final response = await http.get(Uri.parse(url)).timeout(const Duration(seconds: 3)); //TODO: check if this timeout works
if (response.statusCode == 200) {
collectionList = (json.decode(response.body) as List)
.map((i) => Collection.fromJson(i))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment