style: Migrate to very_good_analysis

This commit is contained in:
PapaTutuWawa 2022-07-27 22:44:39 +02:00
parent 16f22dc4ff
commit bdb9ea4b1e
5 changed files with 37 additions and 29 deletions

View File

@ -1,4 +1,8 @@
include: package:flutter_lints/flutter.yaml include: package:very_good_analysis/analysis_options.yaml
linter:
# Additional information about this file can be found at rules:
# https://dart.dev/guides/language/analysis-options public_member_api_docs: false
lines_longer_than_80_chars: false
use_setters_to_change_properties: false
avoid_positional_boolean_parameters: false
avoid_bool_literals_in_conditional_expressions: false

View File

@ -1,40 +1,44 @@
import "package:moxdns/moxdns.dart"; // ignore_for_file: avoid_print
import "package:moxdns_platform_interface/moxdns_platform_interface.dart"; import 'package:flutter/services.dart';
import "package:flutter/services.dart"; import 'package:moxdns/moxdns.dart';
import 'package:moxdns_platform_interface/moxdns_platform_interface.dart';
class MoxdnsLinuxPlugin extends MoxdnsPlatform { class MoxdnsLinuxPlugin extends MoxdnsPlatform {
MoxdnsLinuxPlugin() : _channel = const MethodChannel('me.polynom.moxdns_linux'), super();
final MethodChannel _channel; final MethodChannel _channel;
MoxdnsLinuxPlugin() : _channel = MethodChannel("me.polynom.moxdns_linux"), super();
static void registerWith() { static void registerWith() {
print("MoxdnsLinuxPlugin: Registering implementation"); print('MoxdnsLinuxPlugin: Registering implementation');
MoxdnsPlugin.platform = MoxdnsLinuxPlugin(); MoxdnsPlugin.platform = MoxdnsLinuxPlugin();
} }
@override @override
Future<List<SrvRecord>> srvQuery(String domain, bool dnssec) async { Future<List<SrvRecord>> srvQuery(String domain, bool dnssec) async {
try { try {
final List<dynamic> results = await _channel.invokeMethod("srvQuery", { // TODO(PapaTutuWawa): Handle the result being null
"domain": domain, final results = (await _channel.invokeMethod<List<dynamic>>('srvQuery', {
"dnssec": dnssec 'domain': domain,
}); 'dnssec': dnssec
}))!;
final records = List<SrvRecord>.empty(growable: true); final records = List<SrvRecord>.empty(growable: true);
for (var record in results) { for (final record in results) {
if (record == null) { if (record == null) {
continue; continue;
} }
final rr = Map<String, dynamic>.from(record); final rr = Map<String, String>.from(record as Map<String, String>);
records.add(SrvRecord( records.add(
rr["target"]!, SrvRecord(
rr["port"]! as int, rr['target']!,
rr["priority"]! as int, rr['port']! as int,
rr["weight"]! as int rr['priority']! as int,
)); rr['weight']! as int,
),
);
} }
return records; return records;
} on PlatformException catch(e) { } on PlatformException catch(e) {
print("moxdns_linux: $e"); print('moxdns_linux: $e');
return const []; return const [];
} }
} }

View File

@ -1,7 +1,6 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:moxdns_linux/moxdns_linux_platform_interface.dart';
import 'moxdns_linux_platform_interface.dart';
/// An implementation of [MoxdnsLinuxPlatform] that uses method channels. /// An implementation of [MoxdnsLinuxPlatform] that uses method channels.
class MethodChannelMoxdnsLinux extends MoxdnsLinuxPlatform { class MethodChannelMoxdnsLinux extends MoxdnsLinuxPlatform {

View File

@ -1,7 +1,6 @@
import 'package:moxdns_linux/moxdns_linux_method_channel.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'moxdns_linux_method_channel.dart';
abstract class MoxdnsLinuxPlatform extends PlatformInterface { abstract class MoxdnsLinuxPlatform extends PlatformInterface {
/// Constructs a MoxdnsLinuxPlatform. /// Constructs a MoxdnsLinuxPlatform.
MoxdnsLinuxPlatform() : super(token: _token); MoxdnsLinuxPlatform() : super(token: _token);

View File

@ -11,7 +11,6 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
plugin_platform_interface: 2.1.0
moxdns: moxdns:
hosted: https://pub.polynom.me hosted: https://pub.polynom.me
@ -20,10 +19,13 @@ dependencies:
hosted: https://pub.polynom.me hosted: https://pub.polynom.me
version: 0.1.1 version: 0.1.1
plugin_platform_interface: 2.1.0
dev_dependencies: dev_dependencies:
flutter_lints: ^2.0.0
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0 very_good_analysis: 2.4.0
flutter: flutter:
plugin: plugin: