chore: Fix linter issues

This commit is contained in:
PapaTutuWawa 2023-09-08 21:44:37 +02:00
parent 5dcfc7239a
commit c22b35b4ac
12 changed files with 125 additions and 55 deletions

View File

@ -7,6 +7,7 @@ linter:
avoid_positional_boolean_parameters: false avoid_positional_boolean_parameters: false
avoid_bool_literals_in_conditional_expressions: false avoid_bool_literals_in_conditional_expressions: false
file_names: false file_names: false
one_member_abstracts: false
analyzer: analyzer:
exclude: exclude:

View File

@ -55,11 +55,12 @@ class MyAppState extends State<MyApp> {
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
final result = await MoxxyPickerApi().pickFiles(FilePickerType.image, false); final result = await MoxxyPickerApi()
.pickFiles(FilePickerType.image, false);
if (result.isEmpty) return; if (result.isEmpty) return;
final encDest = result.first! + '.enc'; final encDest = '${result.first!}.enc';
final decDest = result.first! + '.dec'; final decDest = '${result.first!}.dec';
final encResult = await MoxxyCryptographyApi().encryptFile( final encResult = await MoxxyCryptographyApi().encryptFile(
result.first!, result.first!,
encDest, encDest,
@ -69,6 +70,7 @@ class MyAppState extends State<MyApp> {
'SHA-256', 'SHA-256',
); );
if (encResult == null) { if (encResult == null) {
// ignore: avoid_print
print('Failed to encrypt file'); print('Failed to encrypt file');
return; return;
} }
@ -82,6 +84,7 @@ class MyAppState extends State<MyApp> {
'SHA-256', 'SHA-256',
); );
if (decResult == null) { if (decResult == null) {
// ignore: avoid_print
print('Failed to decrypt file'); print('Failed to decrypt file');
return; return;
} }
@ -90,11 +93,9 @@ class MyAppState extends State<MyApp> {
imagePath = decDest; imagePath = decDest;
}); });
}, },
child: Text('Test cryptography'), child: const Text('Test cryptography'),
), ),
if (imagePath != null) Image.file(File(imagePath!)),
if (imagePath != null)
Image.file(File(imagePath!)),
], ],
), ),
), ),

View File

@ -0,0 +1 @@

View File

@ -25,12 +25,18 @@ class MoxxyContactsApi {
static const MessageCodec<Object?> codec = StandardMessageCodec(); static const MessageCodec<Object?> codec = StandardMessageCodec();
Future<void> recordSentMessage(String arg_name, String arg_jid, String? arg_avatarPath, FallbackIconType arg_fallbackIcon) async { Future<void> recordSentMessage(String arg_name, String arg_jid,
String? arg_avatarPath, FallbackIconType arg_fallbackIcon) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyContactsApi.recordSentMessage', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyContactsApi.recordSentMessage',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel.send(<Object?>[
await channel.send(<Object?>[arg_name, arg_jid, arg_avatarPath, arg_fallbackIcon.index]) as List<Object?>?; arg_name,
arg_jid,
arg_avatarPath,
arg_fallbackIcon.index
]) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',

View File

@ -73,12 +73,25 @@ class MoxxyCryptographyApi {
static const MessageCodec<Object?> codec = _MoxxyCryptographyApiCodec(); static const MessageCodec<Object?> codec = _MoxxyCryptographyApiCodec();
Future<CryptographyResult?> encryptFile(String arg_sourcePath, String arg_destPath, Uint8List arg_key, Uint8List arg_iv, CipherAlgorithm arg_algorithm, String arg_hashSpec) async { Future<CryptographyResult?> encryptFile(
String arg_sourcePath,
String arg_destPath,
Uint8List arg_key,
Uint8List arg_iv,
CipherAlgorithm arg_algorithm,
String arg_hashSpec) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.encryptFile', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.encryptFile',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel.send(<Object?>[
await channel.send(<Object?>[arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List<Object?>?; arg_sourcePath,
arg_destPath,
arg_key,
arg_iv,
arg_algorithm.index,
arg_hashSpec
]) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',
@ -95,12 +108,25 @@ class MoxxyCryptographyApi {
} }
} }
Future<CryptographyResult?> decryptFile(String arg_sourcePath, String arg_destPath, Uint8List arg_key, Uint8List arg_iv, CipherAlgorithm arg_algorithm, String arg_hashSpec) async { Future<CryptographyResult?> decryptFile(
String arg_sourcePath,
String arg_destPath,
Uint8List arg_key,
Uint8List arg_iv,
CipherAlgorithm arg_algorithm,
String arg_hashSpec) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.decryptFile', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.decryptFile',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel.send(<Object?>[
await channel.send(<Object?>[arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List<Object?>?; arg_sourcePath,
arg_destPath,
arg_key,
arg_iv,
arg_algorithm.index,
arg_hashSpec
]) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',
@ -117,12 +143,13 @@ class MoxxyCryptographyApi {
} }
} }
Future<Uint8List?> hashFile(String arg_sourcePath, String arg_hashSpec) async { Future<Uint8List?> hashFile(
String arg_sourcePath, String arg_hashSpec) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.hashFile', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.hashFile', codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel
await channel.send(<Object?>[arg_sourcePath, arg_hashSpec]) as List<Object?>?; .send(<Object?>[arg_sourcePath, arg_hashSpec]) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',

View File

@ -18,12 +18,14 @@ class MoxxyMediaApi {
static const MessageCodec<Object?> codec = StandardMessageCodec(); static const MessageCodec<Object?> codec = StandardMessageCodec();
Future<bool> generateVideoThumbnail(String arg_src, String arg_dest, int arg_maxWidth) async { Future<bool> generateVideoThumbnail(
String arg_src, String arg_dest, int arg_maxWidth) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyMediaApi.generateVideoThumbnail', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyMediaApi.generateVideoThumbnail',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel
await channel.send(<Object?>[arg_src, arg_dest, arg_maxWidth]) as List<Object?>?; .send(<Object?>[arg_src, arg_dest, arg_maxWidth]) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',

View File

@ -20,10 +20,10 @@ class MoxxyPlatformApi {
Future<String> getPersistentDataPath() async { Future<String> getPersistentDataPath() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.getPersistentDataPath', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.getPersistentDataPath',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
await channel.send(null) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',
@ -47,10 +47,10 @@ class MoxxyPlatformApi {
Future<String> getCacheDataPath() async { Future<String> getCacheDataPath() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.getCacheDataPath', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.getCacheDataPath',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
await channel.send(null) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',
@ -74,10 +74,10 @@ class MoxxyPlatformApi {
Future<void> openBatteryOptimisationSettings() async { Future<void> openBatteryOptimisationSettings() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.openBatteryOptimisationSettings', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.openBatteryOptimisationSettings',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
await channel.send(null) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',
@ -96,10 +96,10 @@ class MoxxyPlatformApi {
Future<bool> isIgnoringBatteryOptimizations() async { Future<bool> isIgnoringBatteryOptimizations() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.isIgnoringBatteryOptimizations', codec, 'dev.flutter.pigeon.moxxy_native.MoxxyPlatformApi.isIgnoringBatteryOptimizations',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
await channel.send(null) as List<Object?>?;
if (replyList == null) { if (replyList == null) {
throw PlatformException( throw PlatformException(
code: 'channel-error', code: 'channel-error',

View File

@ -3,7 +3,8 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon( @ConfigurePigeon(
PigeonOptions( PigeonOptions(
dartOut: 'lib/pigeon/cryptography.g.dart', dartOut: 'lib/pigeon/cryptography.g.dart',
kotlinOut: 'android/src/main/kotlin/org/moxxy/moxxy_native/cryptography/CryptographyApi.kt', kotlinOut:
'android/src/main/kotlin/org/moxxy/moxxy_native/cryptography/CryptographyApi.kt',
kotlinOptions: KotlinOptions( kotlinOptions: KotlinOptions(
package: 'org.moxxy.moxxy_native.cryptography', package: 'org.moxxy.moxxy_native.cryptography',
), ),
@ -24,11 +25,28 @@ class CryptographyResult {
@HostApi() @HostApi()
abstract class MoxxyCryptographyApi { abstract class MoxxyCryptographyApi {
@async @async
CryptographyResult? encryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm, String hashSpec); CryptographyResult? encryptFile(
String sourcePath,
String destPath,
Uint8List key,
Uint8List iv,
CipherAlgorithm algorithm,
String hashSpec,
);
@async @async
CryptographyResult? decryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm, String hashSpec); CryptographyResult? decryptFile(
String sourcePath,
String destPath,
Uint8List key,
Uint8List iv,
CipherAlgorithm algorithm,
String hashSpec,
);
@async @async
Uint8List? hashFile(String sourcePath, String hashSpec); Uint8List? hashFile(
String sourcePath,
String hashSpec,
);
} }

View File

@ -3,13 +3,13 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon( @ConfigurePigeon(
PigeonOptions( PigeonOptions(
dartOut: 'lib/pigeon/media.g.dart', dartOut: 'lib/pigeon/media.g.dart',
kotlinOut: 'android/src/main/kotlin/org/moxxy/moxxy_native/media/MediaApi.kt', kotlinOut:
'android/src/main/kotlin/org/moxxy/moxxy_native/media/MediaApi.kt',
kotlinOptions: KotlinOptions( kotlinOptions: KotlinOptions(
package: 'org.moxxy.moxxy_native.media', package: 'org.moxxy.moxxy_native.media',
), ),
), ),
) )
@HostApi() @HostApi()
abstract class MoxxyMediaApi { abstract class MoxxyMediaApi {
bool generateVideoThumbnail(String src, String dest, int maxWidth); bool generateVideoThumbnail(String src, String dest, int maxWidth);

View File

@ -3,7 +3,8 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon( @ConfigurePigeon(
PigeonOptions( PigeonOptions(
dartOut: 'lib/pigeon/notifications.g.dart', dartOut: 'lib/pigeon/notifications.g.dart',
kotlinOut: 'android/src/main/kotlin/org/moxxy/moxxy_native/notifications/NotificationsApi.kt', kotlinOut:
'android/src/main/kotlin/org/moxxy/moxxy_native/notifications/NotificationsApi.kt',
kotlinOptions: KotlinOptions( kotlinOptions: KotlinOptions(
package: 'org.moxxy.moxxy_native.notifications', package: 'org.moxxy.moxxy_native.notifications',
), ),
@ -54,9 +55,16 @@ class NotificationMessage {
} }
class MessagingNotification { class MessagingNotification {
const MessagingNotification(this.title, this.id, this.jid, this.messages, const MessagingNotification(
this.channelId, this.isGroupchat, this.extra, this.title,
{this.groupId}); this.id,
this.jid,
this.messages,
this.channelId,
this.isGroupchat,
this.extra, {
this.groupId,
});
/// The title of the conversation. /// The title of the conversation.
final String title; final String title;
@ -91,8 +99,13 @@ enum NotificationIcon {
class RegularNotification { class RegularNotification {
const RegularNotification( const RegularNotification(
this.title, this.body, this.channelId, this.id, this.icon, this.title,
{this.groupId}); this.body,
this.channelId,
this.id,
this.icon, {
this.groupId,
});
/// The title of the notification. /// The title of the notification.
final String title; final String title;
@ -165,6 +178,7 @@ class NotificationGroup {
final String description; final String description;
} }
// ignore: constant_identifier_names
enum NotificationChannelImportance { MIN, HIGH, DEFAULT } enum NotificationChannelImportance { MIN, HIGH, DEFAULT }
class NotificationChannel { class NotificationChannel {

View File

@ -3,13 +3,13 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon( @ConfigurePigeon(
PigeonOptions( PigeonOptions(
dartOut: 'lib/pigeon/picker.g.dart', dartOut: 'lib/pigeon/picker.g.dart',
kotlinOut: 'android/src/main/kotlin/org/moxxy/moxxy_native/picker/PickerApi.kt', kotlinOut:
'android/src/main/kotlin/org/moxxy/moxxy_native/picker/PickerApi.kt',
kotlinOptions: KotlinOptions( kotlinOptions: KotlinOptions(
package: 'org.moxxy.moxxy_native.picker', package: 'org.moxxy.moxxy_native.picker',
), ),
), ),
) )
enum FilePickerType { enum FilePickerType {
/// Pick only image(s) /// Pick only image(s)
image, image,

View File

@ -3,13 +3,13 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon( @ConfigurePigeon(
PigeonOptions( PigeonOptions(
dartOut: 'lib/pigeon/platform.g.dart', dartOut: 'lib/pigeon/platform.g.dart',
kotlinOut: 'android/src/main/kotlin/org/moxxy/moxxy_native/platform/PlatformApi.kt', kotlinOut:
'android/src/main/kotlin/org/moxxy/moxxy_native/platform/PlatformApi.kt',
kotlinOptions: KotlinOptions( kotlinOptions: KotlinOptions(
package: 'org.moxxy.moxxy_native.platform', package: 'org.moxxy.moxxy_native.platform',
), ),
), ),
) )
@HostApi() @HostApi()
abstract class MoxxyPlatformApi { abstract class MoxxyPlatformApi {
String getPersistentDataPath(); String getPersistentDataPath();