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_bool_literals_in_conditional_expressions: false
file_names: false
one_member_abstracts: false
analyzer:
exclude:

View File

@ -55,11 +55,12 @@ class MyAppState extends State<MyApp> {
),
TextButton(
onPressed: () async {
final result = await MoxxyPickerApi().pickFiles(FilePickerType.image, false);
final result = await MoxxyPickerApi()
.pickFiles(FilePickerType.image, false);
if (result.isEmpty) return;
final encDest = result.first! + '.enc';
final decDest = result.first! + '.dec';
final encDest = '${result.first!}.enc';
final decDest = '${result.first!}.dec';
final encResult = await MoxxyCryptographyApi().encryptFile(
result.first!,
encDest,
@ -69,6 +70,7 @@ class MyAppState extends State<MyApp> {
'SHA-256',
);
if (encResult == null) {
// ignore: avoid_print
print('Failed to encrypt file');
return;
}
@ -82,6 +84,7 @@ class MyAppState extends State<MyApp> {
'SHA-256',
);
if (decResult == null) {
// ignore: avoid_print
print('Failed to decrypt file');
return;
}
@ -90,11 +93,9 @@ class MyAppState extends State<MyApp> {
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();
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?>(
'dev.flutter.pigeon.moxxy_native.MoxxyContactsApi.recordSentMessage', codec,
'dev.flutter.pigeon.moxxy_native.MoxxyContactsApi.recordSentMessage',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_name, arg_jid, arg_avatarPath, arg_fallbackIcon.index]) as List<Object?>?;
final List<Object?>? replyList = await channel.send(<Object?>[
arg_name,
arg_jid,
arg_avatarPath,
arg_fallbackIcon.index
]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',

View File

@ -55,7 +55,7 @@ class _MoxxyCryptographyApiCodec extends StandardMessageCodec {
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
case 128:
return CryptographyResult.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
@ -73,12 +73,25 @@ class MoxxyCryptographyApi {
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?>(
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.encryptFile', codec,
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.encryptFile',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List<Object?>?;
final List<Object?>? replyList = await channel.send(<Object?>[
arg_sourcePath,
arg_destPath,
arg_key,
arg_iv,
arg_algorithm.index,
arg_hashSpec
]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
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?>(
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.decryptFile', codec,
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.decryptFile',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List<Object?>?;
final List<Object?>? replyList = await channel.send(<Object?>[
arg_sourcePath,
arg_destPath,
arg_key,
arg_iv,
arg_algorithm.index,
arg_hashSpec
]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
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?>(
'dev.flutter.pigeon.moxxy_native.MoxxyCryptographyApi.hashFile', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_sourcePath, arg_hashSpec]) as List<Object?>?;
final List<Object?>? replyList = await channel
.send(<Object?>[arg_sourcePath, arg_hashSpec]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',

View File

@ -18,12 +18,14 @@ class MoxxyMediaApi {
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?>(
'dev.flutter.pigeon.moxxy_native.MoxxyMediaApi.generateVideoThumbnail', codec,
'dev.flutter.pigeon.moxxy_native.MoxxyMediaApi.generateVideoThumbnail',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_src, arg_dest, arg_maxWidth]) as List<Object?>?;
final List<Object?>? replyList = await channel
.send(<Object?>[arg_src, arg_dest, arg_maxWidth]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',

View File

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

View File

@ -3,7 +3,8 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
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(
package: 'org.moxxy.moxxy_native.cryptography',
),
@ -24,11 +25,28 @@ class CryptographyResult {
@HostApi()
abstract class MoxxyCryptographyApi {
@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
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
Uint8List? hashFile(String sourcePath, String hashSpec);
Uint8List? hashFile(
String sourcePath,
String hashSpec,
);
}

View File

@ -3,13 +3,13 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
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(
package: 'org.moxxy.moxxy_native.media',
),
),
)
@HostApi()
abstract class MoxxyMediaApi {
bool generateVideoThumbnail(String src, String dest, int maxWidth);

View File

@ -3,7 +3,8 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
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(
package: 'org.moxxy.moxxy_native.notifications',
),
@ -54,9 +55,16 @@ class NotificationMessage {
}
class MessagingNotification {
const MessagingNotification(this.title, this.id, this.jid, this.messages,
this.channelId, this.isGroupchat, this.extra,
{this.groupId});
const MessagingNotification(
this.title,
this.id,
this.jid,
this.messages,
this.channelId,
this.isGroupchat,
this.extra, {
this.groupId,
});
/// The title of the conversation.
final String title;
@ -91,8 +99,13 @@ enum NotificationIcon {
class RegularNotification {
const RegularNotification(
this.title, this.body, this.channelId, this.id, this.icon,
{this.groupId});
this.title,
this.body,
this.channelId,
this.id,
this.icon, {
this.groupId,
});
/// The title of the notification.
final String title;
@ -165,6 +178,7 @@ class NotificationGroup {
final String description;
}
// ignore: constant_identifier_names
enum NotificationChannelImportance { MIN, HIGH, DEFAULT }
class NotificationChannel {

View File

@ -3,13 +3,13 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
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(
package: 'org.moxxy.moxxy_native.picker',
),
),
)
enum FilePickerType {
/// Pick only image(s)
image,

View File

@ -3,13 +3,13 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
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(
package: 'org.moxxy.moxxy_native.platform',
),
),
)
@HostApi()
abstract class MoxxyPlatformApi {
String getPersistentDataPath();