chore: clean up flutter analyze warnings

Highlights:
- Add publish_to: 'none' to legacy pubspec.yaml files                                                      - Replace print() with dart:developer log() in Treezor SDK
- Add !context.mounted guards in async callbacks (defensive bug fix)                                                       - Add super.key to widget constructors
- Remove redundant @Default(null) from device_model                                     - Fix implementation_imports in legacy_auth datasources                                        - Add ignore comments for scaffolding code
- Add missing shared_preferences dependency in splash module                                                                                                            Mostly code quality improvements, with one defensive bug fix              context.mounted) and one missing dependency fix (shared_preferences).
This commit is contained in:
2026-04-06 22:21:22 +02:00
parent b63b06ef14
commit 3d267aff37
66 changed files with 504 additions and 490 deletions

View File

@@ -1,29 +1,29 @@
/// Flutter icons SFIcons
/// Copyright (C) 2026 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: SFIcons
/// fonts:
/// - asset: fonts/SFIcons.ttf
///
///
/// * Material Design Icons, Copyright (C) Google, Inc
/// Author: Google
/// License: Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
/// Homepage: https://design.google.com/icons/
///
// Flutter icons SFIcons
// Copyright (C) 2026 by original authors @ fluttericon.com, fontello.com
// This font was generated by FlutterIcon.com, which is derived from Fontello.
//
// To use this font, place it in your fonts/ directory and include the
// following in your pubspec.yaml
//
// flutter:
// fonts:
// - family: SFIcons
// fonts:
// - asset: fonts/SFIcons.ttf
//
//
// * Material Design Icons, Copyright (C) Google, Inc
// Author: Google
// License: Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// Homepage: https://design.google.com/icons/
//
import 'package:flutter/widgets.dart';
class SFIcons {
SFIcons._();
static const _kFontFam = 'SFIcons';
static const String? _kFontPkg = 'design_system';
static const String _kFontPkg = 'design_system';
static const IconData back = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData euro = IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg);

View File

@@ -16,7 +16,7 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('getPlatformVersion test', (WidgetTester tester) async {
final FlutterTreezorEntrustSdkBridge plugin = FlutterTreezorEntrustSdkBridge();
FlutterTreezorEntrustSdkBridge();
// The version string depends on the host platform running the test, so
// just assert that some non-empty string is returned.
});

View File

@@ -1,5 +1,6 @@
import 'package:flutter/services.dart';
import 'package:flutter_treezor_entrust_sdk_bridge/model/antelop_error.dart';
import 'dart:developer' show log;
class CustomerAuthenticatedSignatureModule {
static const _channel = MethodChannel('CustomerAuthenticatedSignature');
@@ -41,7 +42,7 @@ class CustomerAuthenticatedSignatureModule {
?.call();
break;
default:
print('Unknown event received: $eventName');
log('Unknown event received: $eventName');
}
});
}
@@ -86,7 +87,7 @@ class CustomerAuthenticatedSignatureModule {
?.call();
break;
default:
print('Unknown event received: $eventName');
log('Unknown event received: $eventName');
}
});
}
@@ -101,7 +102,7 @@ class CustomerAuthenticatedSignatureModule {
'input': input,
});
} catch (e) {
print("Initialization error: $e");
log("Initialization error: $e");
}
}
@@ -114,7 +115,7 @@ class CustomerAuthenticatedSignatureModule {
defaultCustomerAuthenticatedProcessCallback);
await _channel.invokeMethod('signWithDefaultAuthentication');
} catch (e) {
print("signWithDefaultAuthentication error: $e");
log("signWithDefaultAuthentication error: $e");
}
}
@@ -127,7 +128,7 @@ class CustomerAuthenticatedSignatureModule {
try {
await _channel.invokeMethod('signWithCustomAuthentication');
} catch (e) {
print("signWithCustomAuthentication error: $e");
log("signWithCustomAuthentication error: $e");
}
}
@@ -138,7 +139,7 @@ class CustomerAuthenticatedSignatureModule {
'passcode': passcode,
});
} catch (e) {
print("setPinCustomerCredentials error: $e");
log("setPinCustomerCredentials error: $e");
}
}
@@ -150,7 +151,7 @@ class CustomerAuthenticatedSignatureModule {
'subTitle': subTitle,
});
} catch (e) {
print("setBioCustomerCredentials error: $e");
log("setBioCustomerCredentials error: $e");
}
}
@@ -160,7 +161,7 @@ class CustomerAuthenticatedSignatureModule {
return await _channel
.invokeMethod<String>('getAuthenticationPatternName');
} catch (e) {
print("getAuthenticationPatternName error: $e");
log("getAuthenticationPatternName error: $e");
return null;
}
}
@@ -170,7 +171,7 @@ class CustomerAuthenticatedSignatureModule {
try {
return await _channel.invokeMethod<bool>('isOnline');
} catch (e) {
print("isOnline error: $e");
log("isOnline error: $e");
return null;
}
}
@@ -180,7 +181,7 @@ class CustomerAuthenticatedSignatureModule {
try {
return await _channel.invokeMethod<String>('getMessage');
} catch (e) {
print("getMessage error: $e");
log("getMessage error: $e");
return null;
}
}
@@ -190,7 +191,7 @@ class CustomerAuthenticatedSignatureModule {
try {
return await _channel.invokeMethod<String>('getType');
} catch (e) {
print("getType error: $e");
log("getType error: $e");
return null;
}
}
@@ -200,7 +201,7 @@ class CustomerAuthenticatedSignatureModule {
try {
return await _channel.invokeMethod<String>('getResult');
} catch (e) {
print("getResult error: $e");
log("getResult error: $e");
return null;
}
}
@@ -210,7 +211,7 @@ class CustomerAuthenticatedSignatureModule {
try {
return await _channel.invokeMethod<List<int>>('getInputData');
} catch (e) {
print("getInputData error: $e");
log("getInputData error: $e");
return null;
}
}
@@ -220,7 +221,7 @@ class CustomerAuthenticatedSignatureModule {
try {
await _channel.invokeMethod('clean');
} catch (e) {
print("clean error: $e");
log("clean error: $e");
}
}

View File

@@ -1,6 +1,7 @@
//import '../flutter_treezor_entrust_sdk_bridge_method_channel.dart';
import 'package:flutter/services.dart';
import 'package:flutter_treezor_entrust_sdk_bridge/model/antelop_error.dart';
import 'dart:developer' show log;
class WalletManagerModule {
static const _channel = MethodChannel('WalletManager');
@@ -41,7 +42,7 @@ class WalletManagerModule {
walletManagerCallbacks.onConnectionSuccess?.call();
break;
default:
print('Unknown event received: $eventName');
log('Unknown event received: $eventName');
}
});
}

View File

@@ -1,10 +1,12 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_treezor_entrust_sdk_bridge/model/antelop_error.dart';
import 'dart:developer' show log;
class WalletNotificationService {
// Event channel name, should match the Android side.
static const _eventChannel = EventChannel("wallet_notification_service_events");
static const _eventChannel =
EventChannel("wallet_notification_service_events");
// Singleton instance
//static final WalletNotificationService _instance = WalletNotificationService._internal();
@@ -13,8 +15,8 @@ class WalletNotificationService {
//final StreamController<Map<String, dynamic>> _eventStreamController = StreamController.broadcast();
//WalletNotificationService._internal() {
// Initialize the event listener when the singleton is created.
//_eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
// Initialize the event listener when the singleton is created.
//_eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
//}
// Factory constructor to return the singleton instance.
@@ -23,7 +25,7 @@ class WalletNotificationService {
// Public stream to allow other parts of the app to listen for wallet events.
//Stream<Map<String, dynamic>> get events => _eventStreamController.stream;
// Initialize event callbacks
// Initialize event callbacks
void subscribeWalletEvent(WalletEvents walletEvents) {
eventStream.listen((event) {
final eventName = event['event'] as String;
@@ -50,12 +52,12 @@ class WalletNotificationService {
walletEvents.onCountersUpdated?.call();
break;
default:
print('Unknown event received: $eventName');
log('Unknown event received: $eventName');
}
});
}
/* // Handler for receiving events from the native platform.
/* // Handler for receiving events from the native platform.
void _onEvent(dynamic event) {
if (event is Map) {
// Add the event to the stream if it's in the expected format.
@@ -69,18 +71,15 @@ class WalletNotificationService {
final eventMap = Map<String, dynamic>.from(event);
// Parse the error if present
if (eventMap.containsKey('error') && eventMap['error'] is Map<String, dynamic>) {
eventMap['error'] = AntelopError.fromMap(Map<String, dynamic>.from(eventMap['error']));
if (eventMap.containsKey('error') &&
eventMap['error'] is Map<String, dynamic>) {
eventMap['error'] =
AntelopError.fromMap(Map<String, dynamic>.from(eventMap['error']));
}
return eventMap;
});
}
// Error handler for any errors occurring in the native event channel.
void _onError(dynamic error) {
print("Error receiving wallet notification: $error");
}
// Clean up resources when the instance is disposed.
/*void dispose() {
_eventStreamController.close();
@@ -95,12 +94,11 @@ class WalletEvents {
final void Function()? onWalletDeleted;
final void Function()? onCountersUpdated;
WalletEvents({
this.onWalletLoaded,
this.onWalletLocked,
this.onWalletUnlocked,
this.onLogout,
this.onWalletDeleted,
this.onCountersUpdated
});
}
WalletEvents(
{this.onWalletLoaded,
this.onWalletLocked,
this.onWalletUnlocked,
this.onLogout,
this.onWalletDeleted,
this.onCountersUpdated});
}

View File

@@ -1,5 +1,6 @@
import 'package:flutter/services.dart';
import 'package:flutter_treezor_entrust_sdk_bridge/model/antelop_error.dart';
import 'dart:developer' show log;
class WalletProvisioningModule {
static const _channel = MethodChannel('WalletProvisioning');
@@ -24,7 +25,7 @@ class WalletProvisioningModule {
break;
case 'onInitializationError':
final error = AntelopError.handleError(params?['error']);
if (error != null) callbacks.onInitializationError?.call(error);
callbacks.onInitializationError?.call(error);
break;
case 'onPermissionNotGranted':
final permissions = List<String>.from(params?['permissions'] ?? []);
@@ -42,7 +43,7 @@ class WalletProvisioningModule {
break;
case 'onCheckEligibilityError':
final error = AntelopError.handleError(params?['error']);
if (error != null) callbacks.onCheckEligibilityError?.call(error);
callbacks.onCheckEligibilityError?.call(error);
break;
case 'onProvisioningPending':
callbacks.onProvisioningPending?.call();
@@ -52,10 +53,10 @@ class WalletProvisioningModule {
break;
case 'onProvisioningError':
final error = AntelopError.handleError(params?['error']);
if (error != null) callbacks.onProvisioningError?.call(error);
callbacks.onProvisioningError?.call(error);
break;
default:
print('Unknown event received: $eventName');
log('Unknown event received: $eventName');
}
});
}
@@ -127,10 +128,6 @@ class WalletProvisioningModule {
}
// Helper method to parse AntelopError
AntelopError? _parseError(Map<String, dynamic>? errorMap) {
if (errorMap == null) return null;
return AntelopError.fromMap(errorMap);
}
}
// Callback class for handling Wallet Provisioning events

View File

@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'dart:developer' show log;
class QuestiaApi {
final Dio _dio;
@@ -30,7 +31,7 @@ class QuestiaApi {
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) {
print('URI:${String.fromEnvironment('env')}');
log('URI:${String.fromEnvironment('env')}');
return _dio.post<T>(
path,
data: data,

View File

@@ -9,6 +9,7 @@ class TreezorTokenInterceptor extends Interceptor {
}) : _onTokenExpired = onTokenExpired,
_onUnauthorized = onUnauthorized;
// ignore: unused_field
final void Function() _onTokenExpired;
final void Function() _onUnauthorized;
bool _handling = false;
@@ -38,6 +39,7 @@ class TreezorTokenInterceptor extends Interceptor {
handler.next(err);
}
// ignore: unused_element
String? _extractApiMessage(Object? data) {
if (data == null) return null;

View File

@@ -27,30 +27,30 @@ abstract class DeviceModel with _$DeviceModel {
const factory DeviceModel({
required String id,
@JsonKey(fromJson: _toString) required String identificator,
@Default(null) int? battery,
@Default(null) String? userId,
@Default(null) String? companyId,
@Default(null) String? delegationId,
@Default(null) String? groupId,
int? battery,
String? userId,
String? companyId,
String? delegationId,
String? groupId,
@Default({}) Map<String, dynamic> flags,
@Default(null) List<String>? tags,
@Default(null) String? lastConnection,
@Default(null) String? carrierGenre,
@JsonKey(fromJson: _toNullableString) @Default(null) String? carrierBirthday,
@Default(null) int? carrierWeight,
@Default(null) int? carrierStepLength,
@Default(null) String? carrierName,
@Default(null) String? comment,
@Default(null) String? phone,
@Default(null) String? simId,
@Default(null) Map<String, dynamic>? paymentOptions,
List<String>? tags,
String? lastConnection,
String? carrierGenre,
@JsonKey(fromJson: _toNullableString) String? carrierBirthday,
int? carrierWeight,
int? carrierStepLength,
String? carrierName,
String? comment,
String? phone,
String? simId,
Map<String, dynamic>? paymentOptions,
@Default(DeviceSettingsModel()) DeviceSettingsModel settings,
@Default('') String connectionServer,
@Default('') String protocol,
@Default('') String type,
@Default(null) DeviceCapabilitiesModel? capabilities,
DeviceCapabilitiesModel? capabilities,
@JsonKey(fromJson: _toString) @Default('') String createdAt,
@JsonKey(fromJson: _toNullableString) @Default(null) String? updatedAt,
@JsonKey(fromJson: _toNullableString) String? updatedAt,
}) = _DeviceModel;
factory DeviceModel.fromJson(Map<String, dynamic> json) =>

View File

@@ -536,16 +536,16 @@ return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.co
@JsonSerializable()
class _DeviceModel extends DeviceModel {
const _DeviceModel({required this.id, @JsonKey(fromJson: _toString) required this.identificator, this.battery = null, this.userId = null, this.companyId = null, this.delegationId = null, this.groupId = null, final Map<String, dynamic> flags = const {}, final List<String>? tags = null, this.lastConnection = null, this.carrierGenre = null, @JsonKey(fromJson: _toNullableString) this.carrierBirthday = null, this.carrierWeight = null, this.carrierStepLength = null, this.carrierName = null, this.comment = null, this.phone = null, this.simId = null, final Map<String, dynamic>? paymentOptions = null, this.settings = const DeviceSettingsModel(), this.connectionServer = '', this.protocol = '', this.type = '', this.capabilities = null, @JsonKey(fromJson: _toString) this.createdAt = '', @JsonKey(fromJson: _toNullableString) this.updatedAt = null}): _flags = flags,_tags = tags,_paymentOptions = paymentOptions,super._();
const _DeviceModel({required this.id, @JsonKey(fromJson: _toString) required this.identificator, this.battery, this.userId, this.companyId, this.delegationId, this.groupId, final Map<String, dynamic> flags = const {}, final List<String>? tags, this.lastConnection, this.carrierGenre, @JsonKey(fromJson: _toNullableString) this.carrierBirthday, this.carrierWeight, this.carrierStepLength, this.carrierName, this.comment, this.phone, this.simId, final Map<String, dynamic>? paymentOptions, this.settings = const DeviceSettingsModel(), this.connectionServer = '', this.protocol = '', this.type = '', this.capabilities, @JsonKey(fromJson: _toString) this.createdAt = '', @JsonKey(fromJson: _toNullableString) this.updatedAt}): _flags = flags,_tags = tags,_paymentOptions = paymentOptions,super._();
factory _DeviceModel.fromJson(Map<String, dynamic> json) => _$DeviceModelFromJson(json);
@override final String id;
@override@JsonKey(fromJson: _toString) final String identificator;
@override@JsonKey() final int? battery;
@override@JsonKey() final String? userId;
@override@JsonKey() final String? companyId;
@override@JsonKey() final String? delegationId;
@override@JsonKey() final String? groupId;
@override final int? battery;
@override final String? userId;
@override final String? companyId;
@override final String? delegationId;
@override final String? groupId;
final Map<String, dynamic> _flags;
@override@JsonKey() Map<String, dynamic> get flags {
if (_flags is EqualUnmodifiableMapView) return _flags;
@@ -554,7 +554,7 @@ class _DeviceModel extends DeviceModel {
}
final List<String>? _tags;
@override@JsonKey() List<String>? get tags {
@override List<String>? get tags {
final value = _tags;
if (value == null) return null;
if (_tags is EqualUnmodifiableListView) return _tags;
@@ -562,17 +562,17 @@ class _DeviceModel extends DeviceModel {
return EqualUnmodifiableListView(value);
}
@override@JsonKey() final String? lastConnection;
@override@JsonKey() final String? carrierGenre;
@override final String? lastConnection;
@override final String? carrierGenre;
@override@JsonKey(fromJson: _toNullableString) final String? carrierBirthday;
@override@JsonKey() final int? carrierWeight;
@override@JsonKey() final int? carrierStepLength;
@override@JsonKey() final String? carrierName;
@override@JsonKey() final String? comment;
@override@JsonKey() final String? phone;
@override@JsonKey() final String? simId;
@override final int? carrierWeight;
@override final int? carrierStepLength;
@override final String? carrierName;
@override final String? comment;
@override final String? phone;
@override final String? simId;
final Map<String, dynamic>? _paymentOptions;
@override@JsonKey() Map<String, dynamic>? get paymentOptions {
@override Map<String, dynamic>? get paymentOptions {
final value = _paymentOptions;
if (value == null) return null;
if (_paymentOptions is EqualUnmodifiableMapView) return _paymentOptions;
@@ -584,7 +584,7 @@ class _DeviceModel extends DeviceModel {
@override@JsonKey() final String connectionServer;
@override@JsonKey() final String protocol;
@override@JsonKey() final String type;
@override@JsonKey() final DeviceCapabilitiesModel? capabilities;
@override final DeviceCapabilitiesModel? capabilities;
@override@JsonKey(fromJson: _toString) final String createdAt;
@override@JsonKey(fromJson: _toNullableString) final String? updatedAt;

View File

@@ -18,27 +18,23 @@ Map<String, dynamic> _$DeviceResponseModelToJson(
_DeviceModel _$DeviceModelFromJson(Map<String, dynamic> json) => _DeviceModel(
id: json['id'] as String,
identificator: _toString(json['identificator']),
battery: (json['battery'] as num?)?.toInt() ?? null,
userId: json['userId'] as String? ?? null,
companyId: json['companyId'] as String? ?? null,
delegationId: json['delegationId'] as String? ?? null,
groupId: json['groupId'] as String? ?? null,
battery: (json['battery'] as num?)?.toInt(),
userId: json['userId'] as String?,
companyId: json['companyId'] as String?,
delegationId: json['delegationId'] as String?,
groupId: json['groupId'] as String?,
flags: json['flags'] as Map<String, dynamic>? ?? const {},
tags:
(json['tags'] as List<dynamic>?)?.map((e) => e as String).toList() ??
null,
lastConnection: json['lastConnection'] as String? ?? null,
carrierGenre: json['carrierGenre'] as String? ?? null,
carrierBirthday: json['carrierBirthday'] == null
? null
: _toNullableString(json['carrierBirthday']),
carrierWeight: (json['carrierWeight'] as num?)?.toInt() ?? null,
carrierStepLength: (json['carrierStepLength'] as num?)?.toInt() ?? null,
carrierName: json['carrierName'] as String? ?? null,
comment: json['comment'] as String? ?? null,
phone: json['phone'] as String? ?? null,
simId: json['simId'] as String? ?? null,
paymentOptions: json['paymentOptions'] as Map<String, dynamic>? ?? null,
tags: (json['tags'] as List<dynamic>?)?.map((e) => e as String).toList(),
lastConnection: json['lastConnection'] as String?,
carrierGenre: json['carrierGenre'] as String?,
carrierBirthday: _toNullableString(json['carrierBirthday']),
carrierWeight: (json['carrierWeight'] as num?)?.toInt(),
carrierStepLength: (json['carrierStepLength'] as num?)?.toInt(),
carrierName: json['carrierName'] as String?,
comment: json['comment'] as String?,
phone: json['phone'] as String?,
simId: json['simId'] as String?,
paymentOptions: json['paymentOptions'] as Map<String, dynamic>?,
settings: json['settings'] == null
? const DeviceSettingsModel()
: DeviceSettingsModel.fromJson(json['settings'] as Map<String, dynamic>),
@@ -51,9 +47,7 @@ _DeviceModel _$DeviceModelFromJson(Map<String, dynamic> json) => _DeviceModel(
json['capabilities'] as Map<String, dynamic>,
),
createdAt: json['createdAt'] == null ? '' : _toString(json['createdAt']),
updatedAt: json['updatedAt'] == null
? null
: _toNullableString(json['updatedAt']),
updatedAt: _toNullableString(json['updatedAt']),
);
Map<String, dynamic> _$DeviceModelToJson(_DeviceModel instance) =>

View File

@@ -40,7 +40,7 @@ class WalletBalanceBlock extends ConsumerWidget {
MoneyText(
text: context.translate(
I18n.walletTotal,
args: {'amount': '${totalBalance.toStringAsFixed(2)}'},
args: {'amount': totalBalance.toStringAsFixed(2)},
),
size: 26,
secondarySize: 16,