mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 08:31:19 +00:00
44 lines
1.3 KiB
Dart
44 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:manager_api/api.dart';
|
|
import 'package:mqtt_client/mqtt_server_client.dart';
|
|
import 'package:tablet_app/client.dart';
|
|
import 'dart:convert';
|
|
|
|
|
|
class TabletAppContext with ChangeNotifier{
|
|
Client? clientAPI;
|
|
MqttServerClient? clientMQTT;
|
|
String? id;
|
|
String? host;
|
|
ConfigurationDTO? configuration;
|
|
String? language;
|
|
String? deviceId;
|
|
|
|
TabletAppContext({this.id, this.deviceId, this.host, this.configuration, this.language});
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'deviceId': deviceId,
|
|
'host': host,
|
|
'configuration': configuration == null ? null : jsonEncode(configuration!.toJson()),
|
|
'language': language
|
|
};
|
|
}
|
|
|
|
factory TabletAppContext.fromJson(Map<String, dynamic> json) {
|
|
return new TabletAppContext(
|
|
id: json['id'] as String,
|
|
deviceId: json['deviceId'] as String,
|
|
host: json['host'] as String,
|
|
configuration: json['configuration'] == null ? null : ConfigurationDTO.fromJson(json['configuration']),
|
|
language: json['language'] as String
|
|
);
|
|
}
|
|
|
|
// Implement toString to make it easier to see information about
|
|
@override
|
|
String toString() {
|
|
return 'TabletAppContext{id: $id, deviceId: $deviceId, configuration: $configuration, language: $language, host: $host}';
|
|
}
|
|
} |