Add flutter 3+ support. Update dependencies. Fix code style and format issues.

This commit is contained in:
Igor Kulikov
2022-08-12 13:55:27 +03:00
parent 1a07bcd7a0
commit 944c36ce7b
94 changed files with 3167 additions and 3173 deletions

View File

@@ -5,13 +5,13 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:thingsboard_client/thingsboard_client.dart';
abstract class Utils {
static String createDashboardEntityState(EntityId entityId, {String? entityName, String? entityLabel}) {
var stateObj = [<String, dynamic>{
'params': <String, dynamic>{
'entityId': entityId.toJson()
static String createDashboardEntityState(EntityId entityId,
{String? entityName, String? entityLabel}) {
var stateObj = [
<String, dynamic>{
'params': <String, dynamic>{'entityId': entityId.toJson()}
}
}];
];
if (entityName != null) {
stateObj[0]['params']['entityName'] = entityName;
}
@@ -19,14 +19,13 @@ abstract class Utils {
stateObj[0]['params']['entityLabel'] = entityLabel;
}
var stateJson = json.encode(stateObj);
var encodedUri = Uri.encodeComponent(stateJson);
encodedUri = encodedUri.replaceAllMapped(RegExp(r'%([0-9A-F]{2})'), (match) {
var encodedUri = Uri.encodeComponent(stateJson);
encodedUri =
encodedUri.replaceAllMapped(RegExp(r'%([0-9A-F]{2})'), (match) {
var p1 = match.group(1)!;
return String.fromCharCode(int.parse(p1, radix: 16));
});
return Uri.encodeComponent(
base64.encode(utf8.encode(encodedUri))
);
return Uri.encodeComponent(base64.encode(utf8.encode(encodedUri)));
}
static String? contactToShortAddress(ContactBased contact) {
@@ -47,13 +46,21 @@ abstract class Utils {
}
}
static Widget imageFromBase64(String base64, {Color? color, double? width, double? height, String? semanticLabel}) {
static Widget imageFromBase64(String base64,
{Color? color, double? width, double? height, String? semanticLabel}) {
var uriData = UriData.parse(base64);
if (uriData.mimeType == 'image/svg+xml') {
return SvgPicture.memory(uriData.contentAsBytes(), color: color, width: width, height: height, semanticsLabel: semanticLabel);
return SvgPicture.memory(uriData.contentAsBytes(),
color: color,
width: width,
height: height,
semanticsLabel: semanticLabel);
} else {
return Image.memory(uriData.contentAsBytes(), color: color, width: width, height: height, semanticLabel: semanticLabel);
return Image.memory(uriData.contentAsBytes(),
color: color,
width: width,
height: height,
semanticLabel: semanticLabel);
}
}
}