Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Added lint options and improved to code

Michael Rademaker6a7a18f833aa
diff --git a/console/generic_app/analysis_options.yaml b/console/generic_app/analysis_options.yaml
new file mode 100644
index 000000000..393775706
--- /dev/null
+++ b/console/generic_app/analysis_options.yaml
@@ -0,0 +1,7 @@
+include: package:lint/analysis_options.yaml
+
+analyzer:
+ exclude:
+ - "lib/generated/**"
+ errors:
+ missing_required_param: error
diff --git a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj b/console/generic_app/ios/Runner.xcodeproj/project.pbxproj
index acac977a0..8a5224e0c 100644
--- a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj
+++ b/console/generic_app/ios/Runner.xcodeproj/project.pbxproj
@@ -395,7 +395,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
- CURRENT_PROJECT_VERSION = 13;
+ CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 4AC88KZHJZ;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@@ -530,7 +530,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
- CURRENT_PROJECT_VERSION = 13;
+ CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 4AC88KZHJZ;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@@ -560,7 +560,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
- CURRENT_PROJECT_VERSION = 13;
+ CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 4AC88KZHJZ;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
diff --git a/console/generic_app/ios/Runner/Info.plist b/console/generic_app/ios/Runner/Info.plist
index 8172b5d6e..f0c2481c2 100644
--- a/console/generic_app/ios/Runner/Info.plist
+++ b/console/generic_app/ios/Runner/Info.plist
@@ -24,6 +24,8 @@
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
+ <key>ITSAppUsesNonExemptEncryption</key>
+ <false/>
<key>NSAppleMusicUsageDescription</key>
<string>Permission to Apple Music is needed in order to easly share information</string>
<key>NSCalendarsUsageDescription</key>
@@ -68,10 +70,5 @@
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
- <key>NSAppTransportSecurity</key>
- <dict>
- <key>NSAllowsArbitraryLoads</key>
- <true/>
- </dict>
</dict>
</plist>
diff --git a/console/generic_app/lib/ConsoleProviders/GeoLocation.dart b/console/generic_app/lib/ConsoleProviders/geo_location.dart
similarity index 71%
rename from console/generic_app/lib/ConsoleProviders/GeoLocation.dart
rename to console/generic_app/lib/ConsoleProviders/geo_location.dart
index 0220e17c3..fa7592ada 100644
--- a/console/generic_app/lib/ConsoleProviders/GeoLocation.dart
+++ b/console/generic_app/lib/ConsoleProviders/geo_location.dart
@@ -1,9 +1,9 @@
-import 'package:generic_app/models/GeofenceDefinition.dart';
+import 'package:generic_app/models/geofence_definition.dart';
class GeoLocation {
final GeofenceDefinition geofenceDefinition;
final Map<String, dynamic> data;
GeoLocation(this.geofenceDefinition, {this.data});
-}
\ No newline at end of file
+}
diff --git a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart b/console/generic_app/lib/ConsoleProviders/geofence_provider.dart
similarity index 80%
rename from console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
rename to console/generic_app/lib/ConsoleProviders/geofence_provider.dart
index 65685bf40..8e20e10d1 100644
--- a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
+++ b/console/generic_app/lib/ConsoleProviders/geofence_provider.dart
@@ -1,16 +1,15 @@
import 'dart:convert';
import 'package:flutter/material.dart';
-import 'package:generic_app/ConsoleProviders/GeoLocation.dart';
-import 'package:generic_app/config/CurrentConsoleAppConfig.dart';
-import 'package:generic_app/models/GeofenceDefinition.dart';
-import 'package:generic_app/network/ApiManager.dart';
+import 'package:generic_app/ConsoleProviders/geo_location.dart';
+import 'package:generic_app/models/geofence_definition.dart';
+import 'package:generic_app/network/api_manager.dart';
import 'package:geofencing/geofencing.dart';
import 'package:location/location.dart' as lm;
import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart';
-import 'ProviderConstants.dart';
+import 'provider_constants.dart';
class GeofenceProvider {
static GeofenceProvider _instance;
@@ -40,12 +39,12 @@ class GeofenceProvider {
GeofenceEvent.exit
];
- static void geofenceTriggerCallback(
+ static Future geofenceTriggerCallback(
List<String> ids, Location location, GeofenceEvent event) async {
- GeofenceProvider instance = await GeofenceProvider.getInstance();
+ final GeofenceProvider instance = await GeofenceProvider.getInstance();
if (event == GeofenceEvent.enter) {
ids.forEach((id) {
- GeofenceDefinition geofenceDefinition =
+ final GeofenceDefinition geofenceDefinition =
instance.geofences.firstWhere((element) => element.id == id, orElse: () => null);
if (geofenceDefinition != null) {
instance._queueSendLocation(geofenceDefinition, {
@@ -57,7 +56,7 @@ class GeofenceProvider {
}
if (event == GeofenceEvent.exit) {
ids.forEach((id) {
- GeofenceDefinition geofenceDefinition =
+ final GeofenceDefinition geofenceDefinition =
instance.geofences.firstWhere((element) => element.id == id, orElse: () => null);
if (geofenceDefinition != null) {
instance._queueSendLocation(geofenceDefinition, null);
@@ -72,14 +71,14 @@ class GeofenceProvider {
this._sharedPreferences, this._apiManager, this._locationManager);
factory GeofenceProvider(SharedPreferences sharedPreferences) {
- String geofenceString = sharedPreferences.getString(geofencesKey);
+ final String geofenceString = sharedPreferences.getString(geofencesKey);
List<GeofenceDefinition> geofences;
if (geofenceString != null) {
geofences = List<GeofenceDefinition>.from(json
.decode(geofenceString)
.map((item) => GeofenceDefinition.fromJson(item)));
} else {
- geofences = new List<GeofenceDefinition>();
+ geofences = <GeofenceDefinition>[];
}
return GeofenceProvider._internal(
@@ -88,14 +87,11 @@ class GeofenceProvider {
geofences,
sharedPreferences,
ApiManager(sharedPreferences.getString(baseUrlKey), baseHeaders: {"Content-Type": "application/json", "Accept": "application/json"}),
- new lm.Location());
+ lm.Location());
}
static Future<GeofenceProvider> getInstance() async {
- if (_instance == null) {
- _instance = GeofenceProvider(await SharedPreferences.getInstance());
- }
- return _instance;
+ return _instance ??= GeofenceProvider(await SharedPreferences.getInstance());
}
Future<Map<String, dynamic>> initialize() async {
@@ -112,15 +108,15 @@ class GeofenceProvider {
};
}
- enable(String baseUrl, String consoleId, ProviderCallback callback) async {
- this._baseURL = baseUrl;
- this._consoleId = consoleId;
- this._apiManager.baseUrl = baseUrl;
- await this._sharedPreferences.setString(baseUrlKey, baseUrl);
- await this._sharedPreferences.setString(consoleIdKey, consoleId);
- await this._sharedPreferences.setBool(geoDisabledKey, false);
- await this._sharedPreferences.setString(baseUrlKey, baseUrl);
- this._enableCallback = callback;
+ Future enable(String baseUrl, String consoleId, ProviderCallback callback) async {
+ _baseURL = baseUrl;
+ _consoleId = consoleId;
+ _apiManager.baseUrl = baseUrl;
+ await _sharedPreferences.setString(baseUrlKey, baseUrl);
+ await _sharedPreferences.setString(consoleIdKey, consoleId);
+ await _sharedPreferences.setBool(geoDisabledKey, false);
+ await _sharedPreferences.setString(baseUrlKey, baseUrl);
+ _enableCallback = callback;
if (await Permission.locationAlways.isGranted) {
_startGeofenceProvider();
@@ -130,13 +126,13 @@ class GeofenceProvider {
"hasPermission": await Permission.locationAlways.isGranted,
"success": true
});
- Future.delayed(Duration(seconds: 5)).then((value) => refreshGeofences());
+ Future.delayed(const Duration(seconds: 5)).then((value) => refreshGeofences());
} else {
if (await Permission.locationAlways.isUndetermined) {
Permission.locationAlways.request().then((value) {
if (value.isGranted) {
_startGeofenceProvider();
- Future.delayed(Duration(seconds: 5))
+ Future.delayed(const Duration(seconds: 5))
.then((value) => refreshGeofences());
}
_enableCallback?.call({
@@ -158,7 +154,7 @@ class GeofenceProvider {
}
Future<Map<String, dynamic>> disable() async {
- for (String geofenceId in geofences.map((e) => e.id)) {
+ for (final String geofenceId in geofences.map((e) => e.id)) {
await GeofencingManager.removeGeofenceById(geofenceId);
}
@@ -170,9 +166,9 @@ class GeofenceProvider {
};
}
- addGeofence(GeofenceDefinition geofenceDefinition) async {
+ Future addGeofence(GeofenceDefinition geofenceDefinition) async {
await GeofencingManager.registerGeofence(
- new GeofenceRegion(
+ GeofenceRegion(
geofenceDefinition.id,
geofenceDefinition.lat,
geofenceDefinition.lng,
@@ -180,24 +176,23 @@ class GeofenceProvider {
triggers), geofenceTriggerCallback);
}
- _startGeofenceProvider() async {
+ Future _startGeofenceProvider() async {
await GeofencingManager.initialize();
geofences.forEach((geofence) async {
await addGeofence(geofence);
});
}
- removeGeofence(String id) async {
+ Future removeGeofence(String id) async {
await GeofencingManager.removeGeofenceById(id);
}
- refreshGeofences() async {
+ Future refreshGeofences() async {
_apiManager.getAll<GeofenceDefinition>(["rules", "geofences", _consoleId],
GeofenceDefinition.fromJson).then((geofenceDefinitions) async {
print("Fetched geofences=${geofenceDefinitions.length}");
- List<GeofenceDefinition> remainingGeofences = List.from(geofenceDefinitions);
- new List<GeofenceDefinition>();
+ final List<GeofenceDefinition> remainingGeofences = List.from(geofenceDefinitions);
geofences.forEach((oldGeofence) async {
if (!geofenceDefinitions
.any((definition) => definition.id == oldGeofence.id)) {
@@ -220,7 +215,7 @@ class GeofenceProvider {
});
}
- _queueSendLocation(GeofenceDefinition geofenceDefinition,
+ void _queueSendLocation(GeofenceDefinition geofenceDefinition,
Map<String, dynamic> locationData) {
if (locationData == null) {
_exitedLocation = GeoLocation(geofenceDefinition);
@@ -236,13 +231,13 @@ class GeofenceProvider {
if (!_sendQueued) {
_sendQueued = true;
print("Schedule send location");
- Future.delayed(Duration(seconds: 2)).then((value) {
+ Future.delayed(const Duration(seconds: 2)).then((value) {
_doSendLocation();
});
}
}
- _doSendLocation() async {
+ Future _doSendLocation() async {
print("Do send location");
bool success = false;
@@ -275,7 +270,7 @@ class GeofenceProvider {
}
}
- _sendLocation(GeofenceDefinition geofenceDefinition,
+ Future<bool> _sendLocation(GeofenceDefinition geofenceDefinition,
Map<String, dynamic> locationData) {
return _apiManager
.put(
@@ -291,7 +286,7 @@ class GeofenceProvider {
});
}
- getLocation(ProviderCallback callback, BuildContext context) async {
+ Future getLocation(ProviderCallback callback, BuildContext context) async {
_getLocationCallback = callback;
if (await Permission.locationAlways.isGranted) {
@@ -326,21 +321,21 @@ class GeofenceProvider {
context: context,
builder: (BuildContext context) {
return AlertDialog(
- title: new Text("Location permission denied"),
- content: new Text(
+ title: const Text("Location permission denied"),
+ content: const Text(
"In order to get the location it's necessary to give permissions to the app. Do you want to open the settings?"),
actions: <Widget>[
- new FlatButton(
- child: new Text("Yes"),
+ FlatButton(
onPressed: () {
openAppSettings();
},
+ child: const Text("Yes"),
),
- new FlatButton(
- child: new Text("No"),
+ FlatButton(
onPressed: () {
Navigator.of(context).pop();
},
+ child: const Text("No"),
),
],
);
diff --git a/console/generic_app/lib/ConsoleProviders/ProviderConstants.dart b/console/generic_app/lib/ConsoleProviders/provider_constants.dart
similarity index 100%
rename from console/generic_app/lib/ConsoleProviders/ProviderConstants.dart
rename to console/generic_app/lib/ConsoleProviders/provider_constants.dart
diff --git a/console/generic_app/lib/ConsoleProviders/PushProvider.dart b/console/generic_app/lib/ConsoleProviders/push_provider.dart
similarity index 96%
rename from console/generic_app/lib/ConsoleProviders/PushProvider.dart
rename to console/generic_app/lib/ConsoleProviders/push_provider.dart
index 8f8a2244e..f75fc2031 100644
--- a/console/generic_app/lib/ConsoleProviders/PushProvider.dart
+++ b/console/generic_app/lib/ConsoleProviders/push_provider.dart
@@ -2,7 +2,7 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart';
-import 'ProviderConstants.dart';
+import 'provider_constants.dart';
class PushProvider {
static const String consoleIdKey = "consoleId";
@@ -35,7 +35,7 @@ class PushProvider {
};
}
- enable(String consoleId, ProviderCallback callback) async {
+ Future enable(String consoleId, ProviderCallback callback) async {
_consoleId = consoleId;
await _sharedPreferences.setString(consoleIdKey, consoleId);
await _sharedPreferences.setBool(pushDisabledKey, false);
diff --git a/console/generic_app/lib/ConsoleProviders/StorageProvider.dart b/console/generic_app/lib/ConsoleProviders/storage_provider.dart
similarity index 95%
rename from console/generic_app/lib/ConsoleProviders/StorageProvider.dart
rename to console/generic_app/lib/ConsoleProviders/storage_provider.dart
index b247114fa..82fc84b46 100644
--- a/console/generic_app/lib/ConsoleProviders/StorageProvider.dart
+++ b/console/generic_app/lib/ConsoleProviders/storage_provider.dart
@@ -40,7 +40,7 @@ class StorageProvider {
};
}
- Map<String, dynamic> store(String key, String data) {
+ void store(String key, String data) {
if (data == null) {
_sharedPreferences.remove(key);
} else {
diff --git a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart b/console/generic_app/lib/config/current_console_app_config.dart
similarity index 68%
rename from console/generic_app/lib/config/CurrentConsoleAppConfig.dart
rename to console/generic_app/lib/config/current_console_app_config.dart
index 99180e105..1d819c3bd 100644
--- a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart
+++ b/console/generic_app/lib/config/current_console_app_config.dart
@@ -1,7 +1,7 @@
import 'dart:ui';
-import 'package:generic_app/models/ConsoleAppConfig.dart';
-import 'package:generic_app/models/LinkConfig.dart';
+import 'package:generic_app/models/console_app_config.dart';
+import 'package:generic_app/models/link_config.dart';
import 'package:generic_app/utils/HexColor.dart';
class CurrentConsoleAppConfig {
@@ -10,16 +10,16 @@ class CurrentConsoleAppConfig {
CurrentConsoleAppConfig._privateConstructor();
- updateConfig(ConsoleAppConfig appConfig, String project) {
- this._realm = appConfig.realm;
- this._initialUrl = appConfig.initialUrl;
- this._url = appConfig.url;
- this._menuEnabled = appConfig.menuEnabled;
- this._menuPosition = appConfig.menuPosition;
- this._primaryColor = appConfig.primaryColor;
- this._secondaryColor = appConfig.secondaryColor;
- this._links = appConfig.links;
- this._projectName = project;
+ void updateConfig(ConsoleAppConfig appConfig, String project) {
+ _realm = appConfig.realm;
+ _initialUrl = appConfig.initialUrl;
+ _url = appConfig.url;
+ _menuEnabled = appConfig.menuEnabled;
+ _menuPosition = appConfig.menuPosition;
+ _primaryColor = appConfig.primaryColor;
+ _secondaryColor = appConfig.secondaryColor;
+ _links = appConfig.links;
+ _projectName = project;
}
String _realm;
diff --git a/console/generic_app/lib/events/OpenWebPageEvent.dart b/console/generic_app/lib/events/open_web_page_event.dart
similarity index 100%
rename from console/generic_app/lib/events/OpenWebPageEvent.dart
rename to console/generic_app/lib/events/open_web_page_event.dart
diff --git a/console/generic_app/lib/main.dart b/console/generic_app/lib/main.dart
index 7b75248b6..c5d68c645 100644
--- a/console/generic_app/lib/main.dart
+++ b/console/generic_app/lib/main.dart
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
-import 'package:generic_app/ui/SplashPage.dart';
+import 'package:generic_app/ui/splash_page.dart';
import 'generated/l10n.dart';
diff --git a/console/generic_app/lib/models/AlertAction.dart b/console/generic_app/lib/models/alert_action.dart
similarity index 84%
rename from console/generic_app/lib/models/AlertAction.dart
rename to console/generic_app/lib/models/alert_action.dart
index 5a1a6a6f0..1f3cb0b9c 100644
--- a/console/generic_app/lib/models/AlertAction.dart
+++ b/console/generic_app/lib/models/alert_action.dart
@@ -1,8 +1,8 @@
-import 'package:generic_app/models/BaseModel.dart';
+import 'package:generic_app/models/base_model.dart';
import 'package:json_annotation/json_annotation.dart';
-part 'AlertAction.g.dart';
+part 'alert_action.g.dart';
@JsonSerializable()
class AlertAction implements BaseModel {
@@ -22,5 +22,6 @@ class AlertAction implements BaseModel {
});
static AlertAction fromJson(Map<String, dynamic> json) => _$AlertActionFromJson(json);
+ @override
Map<String, dynamic> toJson() => _$AlertActionToJson(this);
}
diff --git a/console/generic_app/lib/models/AlertAction.g.dart b/console/generic_app/lib/models/alert_action.g.dart
similarity index 96%
rename from console/generic_app/lib/models/AlertAction.g.dart
rename to console/generic_app/lib/models/alert_action.g.dart
index 08a7e3d28..48f0d113b 100644
--- a/console/generic_app/lib/models/AlertAction.g.dart
+++ b/console/generic_app/lib/models/alert_action.g.dart
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-part of 'AlertAction.dart';
+part of 'alert_action.dart';
// **************************************************************************
// JsonSerializableGenerator
diff --git a/console/generic_app/lib/models/AlertButton.dart b/console/generic_app/lib/models/alert_button.dart
similarity index 75%
rename from console/generic_app/lib/models/AlertButton.dart
rename to console/generic_app/lib/models/alert_button.dart
index 200c4c0c4..4e7e0a23d 100644
--- a/console/generic_app/lib/models/AlertButton.dart
+++ b/console/generic_app/lib/models/alert_button.dart
@@ -1,10 +1,10 @@
-import 'package:generic_app/models/BaseModel.dart';
+import 'package:generic_app/models/base_model.dart';
import 'package:json_annotation/json_annotation.dart';
-import 'AlertAction.dart';
+import 'alert_action.dart';
-part 'AlertButton.g.dart';
+part 'alert_button.g.dart';
@JsonSerializable()
class AlertButton implements BaseModel {
@@ -18,5 +18,6 @@ class AlertButton implements BaseModel {
});
static AlertButton fromJson(Map<String, dynamic> json) => _$AlertButtonFromJson(json);
+ @override
Map<String, dynamic> toJson() => _$AlertButtonToJson(this);
}
diff --git a/console/generic_app/lib/models/AlertButton.g.dart b/console/generic_app/lib/models/alert_button.g.dart
similarity index 95%
rename from console/generic_app/lib/models/AlertButton.g.dart
rename to console/generic_app/lib/models/alert_button.g.dart
index af97bdae3..f03dbbdd1 100644
--- a/console/generic_app/lib/models/AlertButton.g.dart
+++ b/console/generic_app/lib/models/alert_button.g.dart
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-part of 'AlertButton.dart';
+part of 'alert_button.dart';
// **************************************************************************
// JsonSerializableGenerator
diff --git a/console/generic_app/lib/models/BaseModel.dart b/console/generic_app/lib/models/base_model.dart
similarity index 100%
rename from console/generic_app/lib/models/BaseModel.dart
rename to console/generic_app/lib/models/base_model.dart
diff --git a/console/generic_app/lib/models/ConsoleAppConfig.dart b/console/generic_app/lib/models/console_app_config.dart
similarity index 86%
rename from console/generic_app/lib/models/ConsoleAppConfig.dart
rename to console/generic_app/lib/models/console_app_config.dart
index 9ee4f657c..d192c4070 100644
--- a/console/generic_app/lib/models/ConsoleAppConfig.dart
+++ b/console/generic_app/lib/models/console_app_config.dart
@@ -1,10 +1,10 @@
-import 'package:generic_app/models/LinkConfig.dart';
+import 'package:generic_app/models/link_config.dart';
import 'package:json_annotation/json_annotation.dart';
-import 'BaseModel.dart';
+import 'base_model.dart';
-part 'ConsoleAppConfig.g.dart';
+part 'console_app_config.g.dart';
@JsonSerializable()
class ConsoleAppConfig implements BaseModel {
@@ -34,5 +34,6 @@ class ConsoleAppConfig implements BaseModel {
});
static ConsoleAppConfig fromJson(Map<String, dynamic> json) => _$ConsoleAppConfigFromJson(json);
+ @override
Map<String, dynamic> toJson() => _$ConsoleAppConfigToJson(this);
}
diff --git a/console/generic_app/lib/models/ConsoleAppConfig.g.dart b/console/generic_app/lib/models/console_app_config.g.dart
similarity index 97%
rename from console/generic_app/lib/models/ConsoleAppConfig.g.dart
rename to console/generic_app/lib/models/console_app_config.g.dart
index 64912da41..f426eef50 100644
--- a/console/generic_app/lib/models/ConsoleAppConfig.g.dart
+++ b/console/generic_app/lib/models/console_app_config.g.dart
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-part of 'ConsoleAppConfig.dart';
+part of 'console_app_config.dart';
// **************************************************************************
// JsonSerializableGenerator
diff --git a/console/generic_app/lib/models/GeofenceDefinition.dart b/console/generic_app/lib/models/geofence_definition.dart
similarity index 87%
rename from console/generic_app/lib/models/GeofenceDefinition.dart
rename to console/generic_app/lib/models/geofence_definition.dart
index 756a79d36..d9e37f301 100644
--- a/console/generic_app/lib/models/GeofenceDefinition.dart
+++ b/console/generic_app/lib/models/geofence_definition.dart
@@ -1,9 +1,9 @@
-import 'package:generic_app/models/BaseModel.dart';
+import 'package:generic_app/models/base_model.dart';
import 'package:json_annotation/json_annotation.dart';
-part 'GeofenceDefinition.g.dart';
+part 'geofence_definition.g.dart';
@JsonSerializable()
class GeofenceDefinition implements BaseModel{
@@ -17,6 +17,7 @@ class GeofenceDefinition implements BaseModel{
GeofenceDefinition({this.id, this.lat, this.lng, this.radius, this.httpMethod, this.url});
static GeofenceDefinition fromJson(Map<String, dynamic> json) => _$GeofenceDefinitionFromJson(json);
+ @override
Map<String, dynamic> toJson() => _$GeofenceDefinitionToJson(this);
@override
diff --git a/console/generic_app/lib/models/GeofenceDefinition.g.dart b/console/generic_app/lib/models/geofence_definition.g.dart
similarity index 96%
rename from console/generic_app/lib/models/GeofenceDefinition.g.dart
rename to console/generic_app/lib/models/geofence_definition.g.dart
index 415bc0448..a38932681 100644
--- a/console/generic_app/lib/models/GeofenceDefinition.g.dart
+++ b/console/generic_app/lib/models/geofence_definition.g.dart
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-part of 'GeofenceDefinition.dart';
+part of 'geofence_definition.dart';
// **************************************************************************
// JsonSerializableGenerator
diff --git a/console/generic_app/lib/models/LinkConfig.dart b/console/generic_app/lib/models/link_config.dart
similarity index 85%
rename from console/generic_app/lib/models/LinkConfig.dart
rename to console/generic_app/lib/models/link_config.dart
index e5a03d2d9..649ac1449 100644
--- a/console/generic_app/lib/models/LinkConfig.dart
+++ b/console/generic_app/lib/models/link_config.dart
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
-import 'BaseModel.dart';
+import 'base_model.dart';
-part 'LinkConfig.g.dart';
+part 'link_config.g.dart';
@JsonSerializable()
class LinkConfig implements BaseModel {
@@ -14,5 +14,6 @@ class LinkConfig implements BaseModel {
LinkConfig(this.displayText, this.pageLink);
static LinkConfig fromJson(Map<String, dynamic> json) => _$LinkConfigFromJson(json);
+ @override
Map<String, dynamic> toJson() => _$LinkConfigToJson(this);
}
diff --git a/console/generic_app/lib/models/LinkConfig.g.dart b/console/generic_app/lib/models/link_config.g.dart
similarity index 95%
rename from console/generic_app/lib/models/LinkConfig.g.dart
rename to console/generic_app/lib/models/link_config.g.dart
index 92250e540..afbd91617 100644
--- a/console/generic_app/lib/models/LinkConfig.g.dart
+++ b/console/generic_app/lib/models/link_config.g.dart
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-part of 'LinkConfig.dart';
+part of 'link_config.dart';
// **************************************************************************
// JsonSerializableGenerator
diff --git a/console/generic_app/lib/network/ApiManager.dart b/console/generic_app/lib/network/api_manager.dart
similarity index 85%
rename from console/generic_app/lib/network/ApiManager.dart
rename to console/generic_app/lib/network/api_manager.dart
index 3eadbfd08..9f072f641 100644
--- a/console/generic_app/lib/network/ApiManager.dart
+++ b/console/generic_app/lib/network/api_manager.dart
@@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
-import '../models/BaseModel.dart';
+import '../models/base_model.dart';
typedef ResponseParser<T extends BaseModel> = T Function(Map<String, dynamic>);
@@ -26,13 +26,13 @@ class ApiManager {
return http.get(_prepareUrl(pathComponents, queryParameters: queryParameters), headers: _prepareHeaders(additionalHeaders)).then((response) {
if (response.statusCode == 200) {
try {
- Map<String, dynamic> json = jsonDecode(response.body);
+ final Map<String, dynamic> json = jsonDecode(response.body);
var jsonData = json;
if (responseBodyDataKey != null && responseBodyDataKey != "") {
jsonData = json[responseBodyDataKey];
}
if (jsonData is List) {
- throw new Exception("Expected json object");
+ throw Exception("Expected json object");
} else {
return responseParser(jsonData) as T;
}
@@ -41,7 +41,7 @@ class ApiManager {
rethrow;
}
} else {
- throw new Exception(
+ throw Exception(
"Response error: ${response.statusCode} - ${response.body}");
}
});
@@ -55,7 +55,7 @@ class ApiManager {
return http.get(_prepareUrl(pathComponents, queryParameters: queryParameters), headers: _prepareHeaders(additionalHeaders)).then((response) {
if (response.statusCode == 200) {
try {
- var json = jsonDecode(response.body);
+ final json = jsonDecode(response.body);
var jsonData = json;
if (responseBodyDataKey != null && responseBodyDataKey != "") {
jsonData = json[responseBodyDataKey];
@@ -70,7 +70,7 @@ class ApiManager {
rethrow;
}
} else {
- throw new Exception(
+ throw Exception(
"Response error: ${response.statusCode} - ${response.body}");
}
});
@@ -87,13 +87,13 @@ class ApiManager {
.then((response) {
if (response.statusCode == 201) {
try {
- var json = jsonDecode(response.body);
+ final json = jsonDecode(response.body);
var jsonData = json;
if (responseBodyDataKey != null && responseBodyDataKey != "") {
jsonData = json[responseBodyDataKey];
}
if (jsonData is List) {
- throw new Exception("Expected json object");
+ throw Exception("Expected json object");
} else {
return responseParser(jsonData) as T;
}
@@ -104,7 +104,7 @@ class ApiManager {
} else if (response.statusCode >= 200 && response.statusCode <= 299) {
return null;
} else {
- throw new Exception(
+ throw Exception(
"Response error: ${response.statusCode} - ${response.body}");
}
});
@@ -119,13 +119,13 @@ class ApiManager {
.then((response) {
if (response.statusCode == 201) {
try {
- var json = jsonDecode(response.body);
+ final json = jsonDecode(response.body);
var jsonData = json;
if (responseBodyDataKey != null && responseBodyDataKey != "") {
jsonData = json[responseBodyDataKey];
}
if (jsonData is List) {
- throw new Exception("Expected json object");
+ throw Exception("Expected json object");
} else {
return responseParser(jsonData) as T;
}
@@ -136,21 +136,21 @@ class ApiManager {
} else if (response.statusCode >= 200 && response.statusCode <= 299) {
return null;
} else {
- throw new Exception(
+ throw Exception(
"Response error: ${response.statusCode} - ${response.body}");
}
});
}
String _prepareUrl(List<String> pathComponents, {Map<String, dynamic> queryParameters}) {
- StringBuffer urlBuffer = new StringBuffer(baseUrl);
+ final StringBuffer urlBuffer = StringBuffer(baseUrl);
pathComponents
- .forEach((pathComponent) => urlBuffer.write("/" + pathComponent));
+ .forEach((pathComponent) => urlBuffer.write("/$pathComponent"));
if (queryParameters != null) {
urlBuffer.write("?");
- List<MapEntry<String, dynamic>> params = queryParameters.entries.toList();
+ final List<MapEntry<String, dynamic>> params = queryParameters.entries.toList();
for (var i = 0; i < params.length; i++) {
if (i > 0) {
urlBuffer.write("&");
@@ -162,8 +162,8 @@ class ApiManager {
}
Map<String, String> _prepareHeaders(Map<String, String> additionalHeaders) {
- Map<String, String> headers =
- baseHeaders != null ? new HashMap.from(baseHeaders) : new HashMap();
+ final Map<String, String> headers =
+ baseHeaders != null ? HashMap.from(baseHeaders) : HashMap();
if (additionalHeaders != null) {
headers.addAll(additionalHeaders);
}
diff --git a/console/generic_app/lib/services/EventBusService.dart b/console/generic_app/lib/services/event_bus_service.dart
similarity index 69%
rename from console/generic_app/lib/services/EventBusService.dart
rename to console/generic_app/lib/services/event_bus_service.dart
index ddb3bb773..b7d421e58 100644
--- a/console/generic_app/lib/services/EventBusService.dart
+++ b/console/generic_app/lib/services/event_bus_service.dart
@@ -10,9 +10,6 @@ class EventBusService {
}
static EventBusService getInstance() {
- if (_instance == null) {
- _instance = EventBusService._internal();
- }
- return _instance;
+ return _instance ??= EventBusService._internal();
}
}
diff --git a/console/generic_app/lib/services/PushNotificationService.dart b/console/generic_app/lib/services/push_notification_service.dart
similarity index 92%
rename from console/generic_app/lib/services/PushNotificationService.dart
rename to console/generic_app/lib/services/push_notification_service.dart
index 44c2362bd..3359423e2 100644
--- a/console/generic_app/lib/services/PushNotificationService.dart
+++ b/console/generic_app/lib/services/push_notification_service.dart
@@ -4,14 +4,14 @@ import 'dart:io';
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/widgets.dart';
-import 'package:generic_app/ConsoleProviders/GeofenceProvider.dart';
-import 'package:generic_app/ConsoleProviders/StorageProvider.dart';
-import 'package:generic_app/events/OpenWebPageEvent.dart';
-import 'package:generic_app/models/AlertAction.dart';
-import 'package:generic_app/models/AlertButton.dart';
+import 'package:generic_app/ConsoleProviders/geofence_provider.dart';
+import 'package:generic_app/ConsoleProviders/storage_provider.dart';
+import 'package:generic_app/events/open_web_page_event.dart';
+import 'package:generic_app/models/alert_action.dart';
+import 'package:generic_app/models/alert_button.dart';
import 'package:url_launcher/url_launcher.dart';
-import 'EventBusService.dart';
+import 'event_bus_service.dart';
Future<dynamic> backgroundMessageHandler(Map<String, dynamic> remoteMessage) async {
print("background: $remoteMessage");
@@ -29,7 +29,7 @@ Future<dynamic> backgroundMessageHandler(Map<String, dynamic> remoteMessage) asy
geofenceProvider.refreshGeofences();
break;
case "STORE":
- StorageProvider storageProvider = await StorageProvider
+ final StorageProvider storageProvider = await StorageProvider
.getInstance();
storageProvider.store(messageData["key"], messageData["value"]);
break;
diff --git a/console/generic_app/lib/ui/ProjectPage.dart b/console/generic_app/lib/ui/project_page.dart
similarity index 85%
rename from console/generic_app/lib/ui/ProjectPage.dart
rename to console/generic_app/lib/ui/project_page.dart
index cfbf17e50..21fedd894 100644
--- a/console/generic_app/lib/ui/ProjectPage.dart
+++ b/console/generic_app/lib/ui/project_page.dart
@@ -1,13 +1,13 @@
import 'package:flutter/material.dart';
-import 'package:generic_app/config/CurrentConsoleAppConfig.dart';
+import 'package:generic_app/config/current_console_app_config.dart';
import 'package:generic_app/generated/l10n.dart';
-import 'package:generic_app/models/ConsoleAppConfig.dart';
-import 'package:generic_app/network/ApiManager.dart';
-import 'package:generic_app/ui/WebViewPage.dart';
+import 'package:generic_app/models/console_app_config.dart';
+import 'package:generic_app/network/api_manager.dart';
+import 'package:generic_app/ui/web_view_page.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ProjectPage extends StatefulWidget {
- ProjectPage({Key key}) : super(key: key);
+ const ProjectPage({Key key}) : super(key: key);
@override
_ProjectPageState createState() => _ProjectPageState();
@@ -36,14 +36,13 @@ class _ProjectPageState extends State<ProjectPage> {
_innerContext = innerContext;
return SafeArea(
child: SingleChildScrollView(
- physics: ClampingScrollPhysics(),
+ physics: const ClampingScrollPhysics(),
child: Align(
- alignment: Alignment.center,
child: Column(children: <Widget>[
Container(
color: Colors.white,
padding:
- EdgeInsets.only(top: 25, left: 50, right: 50),
+ const EdgeInsets.only(top: 25, left: 50, right: 50),
height: MediaQuery.of(context).size.height * 0.4,
child: Image.asset('assets/images/or_logo.png',
fit: BoxFit.contain),
@@ -56,22 +55,23 @@ class _ProjectPageState extends State<ProjectPage> {
Align(
alignment: Alignment.centerLeft,
child: Container(
- padding: EdgeInsets.only(
+ padding: const EdgeInsets.only(
top: 25, left: 25, right: 25),
child: Text(
S.of(context).connectToYourApplication,
- style: TextStyle(
+ style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.black54),
),
)),
Container(
+ padding: const EdgeInsets.all(25),
child: TextField(
cursorColor: CurrentConsoleAppConfig
.instance.primaryColor,
decoration: InputDecoration(
- border: new UnderlineInputBorder(
+ border: const UnderlineInputBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(3),
topRight: Radius.circular(3))),
@@ -88,14 +88,14 @@ class _ProjectPageState extends State<ProjectPage> {
onSubmitted: (inputText) {
FocusScope.of(context).nextFocus();
}),
- padding: EdgeInsets.all(25),
),
Container(
+ padding: const EdgeInsets.fromLTRB(25, 10, 25, 10),
child: TextField(
cursorColor: CurrentConsoleAppConfig
.instance.primaryColor,
decoration: InputDecoration(
- border: new UnderlineInputBorder(
+ border: const UnderlineInputBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(3),
topRight: Radius.circular(3))),
@@ -113,9 +113,9 @@ class _ProjectPageState extends State<ProjectPage> {
_getConsoleAppConfig();
FocusScope.of(context).unfocus();
}),
- padding: EdgeInsets.fromLTRB(25, 10, 25, 10),
),
Container(
+ padding: const EdgeInsets.fromLTRB(25, 10, 25, 10),
child: Align(
alignment: Alignment.centerRight,
child: RaisedButton(
@@ -129,7 +129,6 @@ class _ProjectPageState extends State<ProjectPage> {
},
child: Text(S.of(context).connect)),
),
- padding: EdgeInsets.fromLTRB(25, 10, 25, 10),
)
],
),
@@ -139,7 +138,7 @@ class _ProjectPageState extends State<ProjectPage> {
}
void _getConsoleAppConfig() {
- var apiManager = new ApiManager("https://$_projectName.openremote.io/api/$_realmName");
+ final apiManager = ApiManager("https://$_projectName.openremote.io/api/$_realmName");
apiManager.get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {
_sharedPreferences.setString("project", _projectName);
_sharedPreferences.setString("realm", _realmName);
@@ -153,7 +152,7 @@ class _ProjectPageState extends State<ProjectPage> {
}).catchError((onError) {
print(onError);
Scaffold.of(_innerContext).showSnackBar(
- SnackBar(
+ const SnackBar(
content: Text(
"Error occurred getting app config. Check your input and try again")),
);
diff --git a/console/generic_app/lib/ui/SplashPage.dart b/console/generic_app/lib/ui/splash_page.dart
similarity index 81%
rename from console/generic_app/lib/ui/SplashPage.dart
rename to console/generic_app/lib/ui/splash_page.dart
index 52ed0a80f..3807b0c28 100644
--- a/console/generic_app/lib/ui/SplashPage.dart
+++ b/console/generic_app/lib/ui/splash_page.dart
@@ -2,18 +2,18 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
-import 'package:generic_app/config/CurrentConsoleAppConfig.dart';
-import 'package:generic_app/models/ConsoleAppConfig.dart';
-import 'package:generic_app/network/ApiManager.dart';
-import 'package:generic_app/ui/ProjectPage.dart';
+import 'package:generic_app/config/current_console_app_config.dart';
+import 'package:generic_app/models/console_app_config.dart';
+import 'package:generic_app/network/api_manager.dart';
+import 'package:generic_app/ui/project_page.dart';
import 'package:quick_actions/quick_actions.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../main.dart';
-import 'WebViewPage.dart';
+import 'web_view_page.dart';
class SplashPage extends StatefulWidget {
- SplashPage({Key key}) : super(key: key);
+ const SplashPage({Key key}) : super(key: key);
@override
_SplashPageState createState() => _SplashPageState();
@@ -46,12 +46,12 @@ class _SplashPageState extends State<SplashPage> {
@override
Widget build(BuildContext context) {
- return new FutureBuilder(
- future: Future.delayed(Duration(seconds: 3), _getProjectData),
+ return FutureBuilder(
+ future: Future.delayed(const Duration(seconds: 3), _getProjectData),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
Future.delayed(Duration.zero, () {
- if (snapshot.data) {
+ if (snapshot.data != null) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
@@ -70,9 +70,8 @@ class _SplashPageState extends State<SplashPage> {
Widget _splashIcon() {
return Scaffold(
body: Align(
- alignment: Alignment.center,
child: Container(
- padding: EdgeInsets.all(100),
+ padding: const EdgeInsets.all(100),
child: Image.asset('assets/images/or_splash.png',
fit: BoxFit.contain),
)));
@@ -92,8 +91,8 @@ class _SplashPageState extends State<SplashPage> {
}
Future<bool> _getConsoleAppConfig() async {
- var apiManager =
- new ApiManager("https://$_projectName.openremote.io/api/$_realmName");
+ final apiManager =
+ ApiManager("https://$_projectName.openremote.io/api/$_realmName");
return apiManager
.get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {
CurrentConsoleAppConfig.instance.updateConfig(value, _projectName);
diff --git a/console/generic_app/lib/ui/WebViewPage.dart b/console/generic_app/lib/ui/web_view_page.dart
similarity index 75%
rename from console/generic_app/lib/ui/WebViewPage.dart
rename to console/generic_app/lib/ui/web_view_page.dart
index a01b641c7..9540f8909 100644
--- a/console/generic_app/lib/ui/WebViewPage.dart
+++ b/console/generic_app/lib/ui/web_view_page.dart
@@ -2,19 +2,19 @@ import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
-import 'package:generic_app/ConsoleProviders/GeofenceProvider.dart';
-import 'package:generic_app/ConsoleProviders/PushProvider.dart';
-import 'package:generic_app/ConsoleProviders/StorageProvider.dart';
-import 'package:generic_app/config/CurrentConsoleAppConfig.dart';
-import 'package:generic_app/events/OpenWebPageEvent.dart';
-import 'package:generic_app/models/LinkConfig.dart';
-import 'package:generic_app/services/EventBusService.dart';
-import 'package:generic_app/services/PushNotificationService.dart';
+import 'package:generic_app/ConsoleProviders/geofence_provider.dart';
+import 'package:generic_app/ConsoleProviders/push_provider.dart';
+import 'package:generic_app/ConsoleProviders/storage_provider.dart';
+import 'package:generic_app/config/current_console_app_config.dart';
+import 'package:generic_app/events/open_web_page_event.dart';
+import 'package:generic_app/models/link_config.dart';
+import 'package:generic_app/services/event_bus_service.dart';
+import 'package:generic_app/services/push_notification_service.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter/webview_flutter.dart';
class WebViewPage extends StatefulWidget {
- WebViewPage({Key key, this.title, this.initialUrl}) : super(key: key);
+ const WebViewPage({Key key, this.title, this.initialUrl}) : super(key: key);
final String title;
final String initialUrl;
@@ -56,12 +56,12 @@ class _WebViewPageState extends State<WebViewPage> {
onWebViewCreated: (WebViewController webViewController) {
_controller = webViewController;
},
- javascriptChannels: <JavascriptChannel>[
+ javascriptChannels: <JavascriptChannel>{
_postMessageJavascriptChannel(context),
- ].toSet(),
+ },
navigationDelegate: (navigationRequest) async {
if (navigationRequest.url.startsWith("webbrowser")) {
- String navUrl =
+ final String navUrl =
navigationRequest.url.replaceAll("webbrowser", "https");
if (await canLaunch(navUrl)) {
await launch(navUrl);
@@ -72,7 +72,7 @@ class _WebViewPageState extends State<WebViewPage> {
},
);
- var stack = Stack(children: <Widget>[_webView]);
+ final stack = Stack(children: <Widget>[_webView]);
if (CurrentConsoleAppConfig.instance.menuEnabled) {
switch (CurrentConsoleAppConfig.instance.menuPosition) {
@@ -99,7 +99,7 @@ class _WebViewPageState extends State<WebViewPage> {
return WillPopScope( onWillPop: _onBackPressed, child: Scaffold(body: SafeArea(child: stack)));
}
- _notifyClient(Map<String, dynamic> data) {
+ void _notifyClient(Map<String, dynamic> data) {
final String jsonString = json.encode(data);
_controller.evaluateJavascript(
"OpenRemoteConsole._handleProviderResponse(JSON.stringify($jsonString))");
@@ -109,9 +109,9 @@ class _WebViewPageState extends State<WebViewPage> {
return JavascriptChannel(
name: 'MobileInterface',
onMessageReceived: (JavascriptMessage message) {
- Map<String, dynamic> messageContent = json.decode(message.message);
- String messageType = messageContent["type"];
- Map<String, dynamic> data = messageContent["data"];
+ final Map<String, dynamic> messageContent = json.decode(message.message);
+ final String messageType = messageContent["type"];
+ final Map<String, dynamic> data = messageContent["data"];
switch (messageType) {
case "error":
print("Received WebApp message, error: " + data["error"]);
@@ -120,9 +120,9 @@ class _WebViewPageState extends State<WebViewPage> {
);
break;
case "provider":
- String action = data["action"];
+ final String action = data["action"];
if (action != null) {
- String provider = data["provider"];
+ final String provider = data["provider"];
if (provider == "geofence") {
_handleGeofenceProviderMessage(data);
} else if (provider == "push") {
@@ -137,17 +137,15 @@ class _WebViewPageState extends State<WebViewPage> {
});
}
- _handleGeofenceProviderMessage(Map<String, dynamic> data) async {
- String action = data["action"];
+ Future _handleGeofenceProviderMessage(Map<String, dynamic> data) async {
+ final String action = data["action"];
- if (_geofenceProvider == null) {
- _geofenceProvider = await GeofenceProvider.getInstance();
- }
+ _geofenceProvider ??= await GeofenceProvider.getInstance();
if (action == "PROVIDER_INIT") {
_notifyClient(await _geofenceProvider.initialize());
} else if (action == "PROVIDER_ENABLE") {
- String consoleId = data["consoleId"];
+ final String consoleId = data["consoleId"];
if (consoleId != null) {
await _geofenceProvider.enable(
@@ -165,16 +163,14 @@ class _WebViewPageState extends State<WebViewPage> {
}
}
- _handlePushProviderMessage(Map<String, dynamic> data) async {
- String action = data["action"];
+ Future _handlePushProviderMessage(Map<String, dynamic> data) async {
+ final String action = data["action"];
- if (_pushProvider == null) {
- _pushProvider = await PushProvider.getInstance();
- }
+ _pushProvider ??= await PushProvider.getInstance();
if (action == "PROVIDER_INIT") {
_notifyClient(await _pushProvider.initialize());
} else if (action == "PROVIDER_ENABLE") {
- String consoleId = data["consoleId"];
+ final String consoleId = data["consoleId"];
if (consoleId != null) {
await _pushProvider.enable(
@@ -185,45 +181,50 @@ class _WebViewPageState extends State<WebViewPage> {
}
}
- _handleStorageProviderMessage(Map<String, dynamic> data) async {
- String action = data["action"];
+ Future _handleStorageProviderMessage(Map<String, dynamic> data) async {
+ final String action = data["action"];
- if (_storageProvider == null) {
- _storageProvider = await StorageProvider.getInstance();
- }
+ _storageProvider ??= await StorageProvider.getInstance();
if (action == "PROVIDER_INIT") {
_notifyClient(_storageProvider.initialize());
} else if (action == "PROVIDER_ENABLE") {
_notifyClient(_storageProvider.enable());
} else if (action == "STORE") {
- String key = data["key"];
- String valueJson = data["value"];
+ final String key = data["key"];
+ final String valueJson = data["value"];
_storageProvider.store(key, valueJson);
} else if (action == "RETRIEVE") {
- String key = data["key"];
+ final String key = data["key"];
_notifyClient(_storageProvider.retrieve(key));
}
}
Widget _menuPopup(double offsetX, double offsetY) => PopupMenuButton<int>(
itemBuilder: (context) {
- List<PopupMenuItem<int>> items = new List<PopupMenuItem<int>>();
+ final List<PopupMenuItem<int>> items = <PopupMenuItem<int>>[];
if (CurrentConsoleAppConfig.instance.links == null) return items;
int index = 0;
- for (LinkConfig linkConfig in CurrentConsoleAppConfig.instance.links) {
+ for (final LinkConfig linkConfig in CurrentConsoleAppConfig.instance.links) {
items.add(PopupMenuItem(
value: index++,
child: Text(
linkConfig.displayText,
- style: TextStyle(color: Colors.black87),
+ style: const TextStyle(color: Colors.black87),
),
));
}
return items;
},
+ offset: Offset(offsetX, offsetY * CurrentConsoleAppConfig.instance.links?.length ?? 1),
+ elevation: 2,
+ onSelected: (selectedValue) {
+ final LinkConfig linkConfig =
+ CurrentConsoleAppConfig.instance.links[selectedValue];
+ _controller.loadUrl(Uri.encodeFull(linkConfig.pageLink));
+ },
child: Container(
height: 50,
width: 50,
@@ -238,15 +239,8 @@ class _WebViewPageState extends State<WebViewPage> {
),
]
),
- child: Icon(Icons.menu),
+ child: const Icon(Icons.menu),
),
- offset: Offset(offsetX, offsetY * CurrentConsoleAppConfig.instance.links?.length ?? 1),
- elevation: 2,
- onSelected: (selectedValue) {
- LinkConfig linkConfig =
- CurrentConsoleAppConfig.instance.links[selectedValue];
- _controller.loadUrl(Uri.encodeFull(linkConfig.pageLink));
- },
);
Future<bool> _onBackPressed() async {
diff --git a/console/generic_app/pubspec.lock b/console/generic_app/pubspec.lock
index 5af2523ee..683206149 100644
--- a/console/generic_app/pubspec.lock
+++ b/console/generic_app/pubspec.lock
@@ -392,6 +392,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.1"
+ lint:
+ dependency: "direct dev"
+ description:
+ name: lint
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.3.0"
+ linter:
+ dependency: "direct dev"
+ description:
+ name: linter
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.118"
location:
dependency: "direct main"
description:
@@ -867,5 +881,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
- dart: ">=2.9.0-14.0.dev <3.0.0"
+ dart: ">=2.9.0-16.0.dev <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
diff --git a/console/generic_app/pubspec.yaml b/console/generic_app/pubspec.yaml
index 0eaea0d47..8a5654927 100644
--- a/console/generic_app/pubspec.yaml
+++ b/console/generic_app/pubspec.yaml
@@ -11,7 +11,7 @@ description: Generic app of OpenRemote
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.0.1+14
+version: 1.0.1+15
environment:
sdk: ">=2.2.0 <3.0.0"
@@ -48,6 +48,8 @@ dev_dependencies:
build_runner: 1.8.1
json_serializable: 3.4.1
flutter_launcher_icons: ^0.8.0
+ linter: ^0.1.116
+ lint: ^1.3.0
flutter_icons:
android: "launcher_icon"