style: Lint using very_good_analysis

This commit is contained in:
PapaTutuWawa 2022-09-06 14:08:36 +02:00
parent acd186e0b6
commit 3aad6b617d
30 changed files with 231 additions and 254 deletions

View File

@ -4,6 +4,14 @@ Platform-specific code for Moxxy. Not intended for use outside of Moxxy.
This repo is based on [very_good_flutter_plugin](https://github.com/VeryGoodOpenSource/very_good_flutter_plugin). This repo is based on [very_good_flutter_plugin](https://github.com/VeryGoodOpenSource/very_good_flutter_plugin).
## Development
The development of this package is based on [melos](https://pub.dev/packages/melos).
To make all packages link to each other locally, begin by running `melos bootstrap`. After editing
the code and making your changes, please run `melos run analyze` to make sure that no linter warnings
are left inside the code.
## Acknowledgements ## Acknowledgements
- [ekasetiawans](https://github.com/ekasetiawans) for [flutter_background_service](https://github.com/ekasetiawans/flutter_background_service). moxplatform_android is basically just a copy and paste of [flutter_background_service](https://github.com/ekasetiawans/flutter_background_service). - [ekasetiawans](https://github.com/ekasetiawans) for [flutter_background_service](https://github.com/ekasetiawans/flutter_background_service). moxplatform_android is basically just a copy and paste of [flutter_background_service](https://github.com/ekasetiawans/flutter_background_service).

View File

@ -1,3 +1,8 @@
analyzer: include: package:very_good_analysis/analysis_options.yaml
exclude: linter:
- brick/** rules:
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

@ -0,0 +1 @@
include: ../../analysis_options.yaml

View File

@ -1,12 +1,4 @@
import "package:moxplatform_platform_interface/moxplatform_platform_interface.dart"; library moxplatform;
import "package:moxplatform_platform_interface/src/isolate.dart";
import "package:moxplatform_platform_interface/src/media.dart";
export "package:moxplatform_platform_interface/src/isolate.dart" show IsolateHandler; export 'src/plugin.dart';
export "package:moxplatform_platform_interface/src/media.dart" show MediaScannerImplementation; export 'src/types.dart';
export "package:moxplatform_platform_interface/src/service.dart" show BackgroundService;
class MoxplatformPlugin {
static IsolateHandler get handler => MoxplatformInterface.handler;
static MediaScannerImplementation get media => MoxplatformInterface.media;
}

View File

@ -0,0 +1,6 @@
import 'package:moxplatform_platform_interface/moxplatform_platform_interface.dart';
class MoxplatformPlugin {
static IsolateHandler get handler => MoxplatformInterface.handler;
static MediaScannerImplementation get media => MoxplatformInterface.media;
}

View File

@ -1,4 +1,4 @@
import "package:moxlib/awaitabledatasender.dart"; import 'package:moxlib/awaitabledatasender.dart';
abstract class BackgroundCommand implements JsonImplementation {} abstract class BackgroundCommand implements JsonImplementation {}
abstract class BackgroundEvent implements JsonImplementation {} abstract class BackgroundEvent implements JsonImplementation {}

View File

@ -19,6 +19,10 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
moxlib:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.4
moxplatform_android: moxplatform_android:
hosted: https://git.polynom.me/api/packages/Moxxy/pub hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.11 version: 0.1.11
@ -26,11 +30,8 @@ dependencies:
hosted: https://git.polynom.me/api/packages/Moxxy/pub hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.11 version: 0.1.11
moxlib:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
plugin_platform_interface: 2.1.2 plugin_platform_interface: 2.1.2
very_good_analysis: 2.4.0

View File

@ -0,0 +1 @@
include: ../../analysis_options.yaml

View File

@ -1,15 +1,6 @@
import "package:moxplatform_android/isolate_android.dart"; library moxplatform_android;
import "package:moxplatform_android/media_android.dart";
import "package:moxplatform_platform_interface/moxplatform_platform_interface.dart"; export 'src/isolate_android.dart';
export 'src/media_android.dart';
class MoxplatformAndroidPlugin extends MoxplatformInterface { export 'src/plugin_android.dart';
static void registerWith() { export 'src/service_android.dart';
print("MoxplatformAndroidPlugin: Registering implementation");
MoxplatformInterface.handler = AndroidIsolateHandler();
MoxplatformInterface.media = AndroidMediaScannerImplementation();
}
@override
Future<String> getPlatformName() async => "Android";
}

View File

@ -1,17 +0,0 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'moxplatform_android_platform_interface.dart';
/// An implementation of [MoxplatformAndroidPlatform] that uses method channels.
class MethodChannelMoxplatformAndroid extends MoxplatformAndroidPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('moxplatform_android');
@override
Future<String?> getPlatformVersion() async {
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
return version;
}
}

View File

@ -1,29 +0,0 @@
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'moxplatform_android_method_channel.dart';
abstract class MoxplatformAndroidPlatform extends PlatformInterface {
/// Constructs a MoxplatformAndroidPlatform.
MoxplatformAndroidPlatform() : super(token: _token);
static final Object _token = Object();
static MoxplatformAndroidPlatform _instance = MethodChannelMoxplatformAndroid();
/// The default instance of [MoxplatformAndroidPlatform] to use.
///
/// Defaults to [MethodChannelMoxplatformAndroid].
static MoxplatformAndroidPlatform get instance => _instance;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [MoxplatformAndroidPlatform] when
/// they register themselves.
static set instance(MoxplatformAndroidPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
Future<String?> getPlatformVersion() {
throw UnimplementedError('platformVersion() has not been implemented.');
}
}

View File

@ -1,63 +0,0 @@
import "dart:convert";
import "dart:ui";
import "package:moxplatform_platform_interface/src/service.dart";
import "package:moxplatform/types.dart";
import "package:moxlib/awaitabledatasender.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:logging/logging.dart";
import "package:uuid/uuid.dart";
import "package:meta/meta.dart";
class AndroidBackgroundService extends BackgroundService {
@internal
static const MethodChannel channel = MethodChannel("me.polynom.moxplatform_android_bg");
final Logger _log;
AndroidBackgroundService()
: _log = Logger("AndroidBackgroundService"),
super();
@override
void setNotification(String title, String body) {
channel.invokeMethod(
"setNotificationBody",
[ body ]
);
}
@override
void sendEvent(BackgroundEvent event, { String? id }) {
final data = DataWrapper(
id ?? const Uuid().v4(),
event
);
// NOTE: *S*erver to *F*oreground
_log.fine("S2F: ${data.toJson().toString()}");
channel.invokeMethod("sendData", jsonEncode(data.toJson()));
}
@override
void init(
Future<void> Function() entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleEvent
) {
WidgetsFlutterBinding.ensureInitialized();
// Ensure that all native plugins are registered against this FlutterEngine, so that
// we can use path_provider, notifications, ...
DartPluginRegistrant.ensureInitialized();
// Register the event handler
channel.setMethodCallHandler((MethodCall call) async {
await handleEvent(jsonDecode(call.arguments));
});
setNotification("Moxxy", "Preparing...");
_log.finest("Running...");
entrypoint();
}
}

View File

@ -1,31 +1,31 @@
import "dart:convert"; import 'dart:convert';
import "dart:ui"; import 'dart:ui';
import 'package:flutter/services.dart';
import "package:moxplatform_android/service_android.dart"; import 'package:flutter/widgets.dart';
import 'package:get_it/get_it.dart';
import "package:flutter/widgets.dart"; import 'package:logging/logging.dart';
import "package:flutter/services.dart"; import 'package:moxlib/awaitabledatasender.dart';
import "package:logging/logging.dart"; import 'package:moxplatform/moxplatform.dart';
import "package:moxplatform_platform_interface/src/isolate.dart"; import 'package:moxplatform_android/src/service_android.dart';
import "package:moxplatform_platform_interface/src/service.dart"; import 'package:moxplatform_platform_interface/moxplatform_platform_interface.dart';
import "package:moxplatform/types.dart";
import "package:moxlib/awaitabledatasender.dart";
import "package:get_it/get_it.dart";
/// An [AwaitableDataSender] that uses flutter_background_service. /// An [AwaitableDataSender] that uses flutter_background_service.
class BackgroundServiceDataSender extends AwaitableDataSender<BackgroundCommand, BackgroundEvent> { class BackgroundServiceDataSender extends AwaitableDataSender<BackgroundCommand, BackgroundEvent> {
BackgroundServiceDataSender()
: _channel = const MethodChannel('me.polynom.moxplatform_android'), super();
final MethodChannel _channel; final MethodChannel _channel;
BackgroundServiceDataSender() : _channel = MethodChannel("me.polynom.moxplatform_android"), super();
@override @override
Future<void> sendDataImpl(DataWrapper data) async { Future<void> sendDataImpl(DataWrapper data) async {
await _channel.invokeMethod("sendData", jsonEncode(data.toJson())); await _channel.invokeMethod<void>('sendData', jsonEncode(data.toJson()));
} }
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
Future<void> androidEntrypoint() async { Future<void> androidEntrypoint() async {
print("androidEntrypoint: Called on new FlutterEngine"); // ignore: avoid_print
print('androidEntrypoint: Called on new FlutterEngine');
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
/* /*
@ -33,11 +33,15 @@ Future<void> androidEntrypoint() async {
print(call.method); print(call.method);
});*/ });*/
final data = jsonDecode(await AndroidBackgroundService.channel.invokeMethod("getExtraData", [])); final result = await AndroidBackgroundService.channel.invokeMethod<String>(
final int entrypointHandle = data["genericEntrypoint"]!; 'getExtraData',
<void>[],
);
final data = jsonDecode(result!) as Map<String, dynamic>;
final entrypointHandle = data['genericEntrypoint']! as int;
final entrypointCallbackHandle = CallbackHandle.fromRawHandle(entrypointHandle); final entrypointCallbackHandle = CallbackHandle.fromRawHandle(entrypointHandle);
final entrypoint = PluginUtilities.getCallbackFromHandle(entrypointCallbackHandle); final entrypoint = PluginUtilities.getCallbackFromHandle(entrypointCallbackHandle);
final int handleUIEventHandle = data["eventHandle"]!; final handleUIEventHandle = data['eventHandle']! as int;
final handleUIEventCallbackHandle = CallbackHandle.fromRawHandle(handleUIEventHandle); final handleUIEventCallbackHandle = CallbackHandle.fromRawHandle(handleUIEventHandle);
final handleUIEvent = PluginUtilities.getCallbackFromHandle(handleUIEventCallbackHandle); final handleUIEvent = PluginUtilities.getCallbackFromHandle(handleUIEventCallbackHandle);
@ -45,26 +49,27 @@ Future<void> androidEntrypoint() async {
GetIt.I.registerSingleton<BackgroundService>(srv); GetIt.I.registerSingleton<BackgroundService>(srv);
srv.init( srv.init(
entrypoint! as Future<void> Function(), entrypoint! as Future<void> Function(),
handleUIEvent! as Future<void> Function(Map<String, dynamic>? data) handleUIEvent! as Future<void> Function(Map<String, dynamic>? data),
); );
} }
/// The Android specific implementation of the [IsolateHandler]. /// The Android specific implementation of the [IsolateHandler].
class AndroidIsolateHandler extends IsolateHandler { class AndroidIsolateHandler extends IsolateHandler {
AndroidIsolateHandler()
: _channel = const MethodChannel('me.polynom.moxplatform_android'),
_dataSender = BackgroundServiceDataSender(),
_log = Logger('AndroidIsolateHandler'),
super();
final BackgroundServiceDataSender _dataSender; final BackgroundServiceDataSender _dataSender;
final MethodChannel _channel; final MethodChannel _channel;
final Logger _log; final Logger _log;
AndroidIsolateHandler()
: _channel = MethodChannel("me.polynom.moxplatform_android"),
_dataSender = BackgroundServiceDataSender(),
_log = Logger("AndroidIsolateHandler"),
super();
@override @override
Future<void> attach(Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent) async { Future<void> attach(Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent) async {
_channel.setMethodCallHandler((MethodCall call) async { _channel.setMethodCallHandler((MethodCall call) async {
await handleIsolateEvent(jsonDecode(call.arguments)); final args = call.arguments as String;
await handleIsolateEvent(jsonDecode(args) as Map<String, dynamic>);
}); });
} }
@ -72,35 +77,35 @@ class AndroidIsolateHandler extends IsolateHandler {
Future<void> start( Future<void> start(
Future<void> Function() entrypoint, Future<void> Function() entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleUIEvent, Future<void> Function(Map<String, dynamic>? data) handleUIEvent,
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
) async { ) async {
_log.finest("Called start"); _log.finest('Called start');
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
final androidEntrypointHandle = PluginUtilities.getCallbackHandle(androidEntrypoint)!.toRawHandle(); final androidEntrypointHandle = PluginUtilities.getCallbackHandle(androidEntrypoint)!.toRawHandle();
_log.finest('androidEntrypointHandle: $androidEntrypointHandle'); _log.finest('androidEntrypointHandle: $androidEntrypointHandle');
await _channel.invokeMethod("configure", [ await _channel.invokeMethod<void>('configure', <dynamic>[
androidEntrypointHandle, androidEntrypointHandle,
jsonEncode({ jsonEncode({
"genericEntrypoint": PluginUtilities.getCallbackHandle(entrypoint)!.toRawHandle(), 'genericEntrypoint': PluginUtilities.getCallbackHandle(entrypoint)!.toRawHandle(),
"eventHandle": PluginUtilities.getCallbackHandle(handleUIEvent)!.toRawHandle() 'eventHandle': PluginUtilities.getCallbackHandle(handleUIEvent)!.toRawHandle()
}), }),
]); ]);
await attach(handleIsolateEvent); await attach(handleIsolateEvent);
final result = await _channel.invokeMethod("start", []); final result = await _channel.invokeMethod<bool>('start', <void>[]);
if (result) { if (result == true) {
_log.finest("Service successfully started"); _log.finest('Service successfully started');
} else { } else {
_log.severe("Service failed to start"); _log.severe('Service failed to start');
} }
} }
@override @override
Future<bool> isRunning() async { Future<bool> isRunning() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
return await _channel.invokeMethod("isRunning", []); return (await _channel.invokeMethod<bool>('isRunning', <void>[])) == true;
} }
@override @override

View File

@ -1,5 +1,5 @@
import "package:moxplatform_platform_interface/src/media.dart"; import 'package:media_scanner/media_scanner.dart';
import "package:media_scanner/media_scanner.dart"; import 'package:moxplatform_platform_interface/moxplatform_platform_interface.dart';
class AndroidMediaScannerImplementation extends MediaScannerImplementation { class AndroidMediaScannerImplementation extends MediaScannerImplementation {
@override @override

View File

@ -0,0 +1,15 @@
import 'package:moxplatform_android/src/isolate_android.dart';
import 'package:moxplatform_android/src/media_android.dart';
import 'package:moxplatform_platform_interface/moxplatform_platform_interface.dart';
class MoxplatformAndroidPlugin extends MoxplatformInterface {
static void registerWith() {
// ignore: avoid_print
print('MoxplatformAndroidPlugin: Registering implementation');
MoxplatformInterface.handler = AndroidIsolateHandler();
MoxplatformInterface.media = AndroidMediaScannerImplementation();
}
@override
Future<String> getPlatformName() async => 'Android';
}

View File

@ -0,0 +1,64 @@
import 'dart:convert';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:moxlib/awaitabledatasender.dart';
import 'package:moxplatform/moxplatform.dart';
import 'package:moxplatform_platform_interface/moxplatform_platform_interface.dart';
import 'package:uuid/uuid.dart';
class AndroidBackgroundService extends BackgroundService {
AndroidBackgroundService()
: _log = Logger('AndroidBackgroundService'),
super();
@internal
static const MethodChannel channel = MethodChannel('me.polynom.moxplatform_android_bg');
final Logger _log;
@override
void setNotification(String title, String body) {
channel.invokeMethod<void>(
'setNotificationBody',
[body],
);
}
@override
void sendEvent(BackgroundEvent event, { String? id }) {
final data = DataWrapper(
id ?? const Uuid().v4(),
event,
);
// NOTE: *S*erver to *F*oreground
_log.fine('S2F: ${data.toJson().toString()}');
channel.invokeMethod<void>('sendData', jsonEncode(data.toJson()));
}
@override
void init(
Future<void> Function() entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleEvent,
) {
WidgetsFlutterBinding.ensureInitialized();
// Ensure that all native plugins are registered against this FlutterEngine, so that
// we can use path_provider, notifications, ...
DartPluginRegistrant.ensureInitialized();
// Register the event handler
channel.setMethodCallHandler((MethodCall call) async {
final args = call.arguments! as String;
await handleEvent(jsonDecode(args) as Map<String, dynamic>);
});
setNotification('Moxxy', 'Preparing...');
_log.finest('Running...');
entrypoint();
}
}

View File

@ -20,23 +20,25 @@ flutter:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
moxplatform_platform_interface: get_it: 7.2.0
hosted: https://git.polynom.me/api/packages/Moxxy/pub logging: 1.0.2
version: 0.1.11 media_scanner: 2.0.0
moxplatform: meta: ^1.7.0
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.11
moxlib: moxlib:
hosted: https://git.polynom.me/api/packages/Moxxy/pub hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.4 version: 0.1.4
logging: 1.0.2
get_it: 7.2.0 moxplatform:
uuid: 3.0.5 hosted: https://git.polynom.me/api/packages/Moxxy/pub
media_scanner: 2.0.0 version: 0.1.11
moxplatform_platform_interface:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.11
plugin_platform_interface: 2.1.2 plugin_platform_interface: 2.1.2
meta: ^1.7.0 uuid: 3.0.5
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
very_good_analysis: 2.4.0

View File

@ -1,4 +1 @@
include: package:flutter_lints/flutter.yaml include: ../../analysis_options.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -30,3 +30,4 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0
very_good_analysis: 2.4.0

View File

@ -1,4 +1 @@
include: package:flutter_lints/flutter.yaml include: ../../analysis_options.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -12,9 +12,8 @@ dependencies:
sdk: flutter sdk: flutter
moxplatform: moxplatform:
path: ../moxplatform hosted: https://git.polynom.me/api/packages/Moxxy/pub
#hosted: https://git.polynom.me/api/packages/Moxxy/pub version: 0.1.11
#version: 0.1.11
moxplatform_generic: moxplatform_generic:
path: ../moxplatform_generic path: ../moxplatform_generic
@ -22,6 +21,7 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0
very_good_analysis: 2.4.0
flutter: flutter:
plugin: plugin:

View File

@ -0,0 +1 @@
include: ../../analysis_options.yaml

View File

@ -1,29 +1,8 @@
import "package:moxplatform_platform_interface/src/isolate.dart"; library moxplatform_platform_interface;
import "package:moxplatform_platform_interface/src/isolate_stub.dart";
import "package:moxplatform_platform_interface/src/media.dart";
import "package:moxplatform_platform_interface/src/media_stub.dart";
import "package:plugin_platform_interface/plugin_platform_interface.dart";
abstract class MoxplatformInterface extends PlatformInterface { export 'src/interface.dart';
/// Constructs a MyPluginPlatform. export 'src/isolate.dart';
MoxplatformInterface() : super(token: _token); export 'src/isolate_stub.dart';
export 'src/media.dart';
static final Object _token = Object(); export 'src/media_stub.dart';
export 'src/service.dart';
static IsolateHandler _handler = StubIsolateHandler();
static MediaScannerImplementation _media = StubMediaScannerImplementation();
static IsolateHandler get handler => _handler;
static set handler(IsolateHandler instance) {
_handler = instance;
}
static MediaScannerImplementation get media => _media;
static set media(MediaScannerImplementation instance) {
_media = instance;
}
/// Return the current platform name.
Future<String?> getPlatformName();
}

View File

@ -0,0 +1,17 @@
import 'package:moxplatform_platform_interface/src/isolate.dart';
import 'package:moxplatform_platform_interface/src/isolate_stub.dart';
import 'package:moxplatform_platform_interface/src/media.dart';
import 'package:moxplatform_platform_interface/src/media_stub.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
abstract class MoxplatformInterface extends PlatformInterface {
MoxplatformInterface() : super(token: _token);
static final Object _token = Object();
static IsolateHandler handler = StubIsolateHandler();
static MediaScannerImplementation media = StubMediaScannerImplementation();
/// Return the current platform name.
Future<String?> getPlatformName();
}

View File

@ -1,4 +1,4 @@
import "package:moxlib/awaitabledatasender.dart"; import 'package:moxlib/awaitabledatasender.dart';
/// A class abstracting the interaction between the UI isolate and the background /// A class abstracting the interaction between the UI isolate and the background
/// service, which is either a regular isolate or an Android foreground service. /// service, which is either a regular isolate or an Android foreground service.
@ -6,17 +6,17 @@ import "package:moxlib/awaitabledatasender.dart";
abstract class IsolateHandler { abstract class IsolateHandler {
/// Start the background service. /// Start the background service.
/// [entrypoint] is the entrypoint that is run inside the new isolate. /// [entrypoint] is the entrypoint that is run inside the new isolate.
/// [handeUiEvent] is a handler function that is called when the isolate receives data from the UI. /// [handleUIEvent] is a handler function that is called when the isolate receives data from the UI.
/// [handleIsolateEvent] is a handler function that is called when the UI receives data from the service. /// [handleIsolateEvent] is a handler function that is called when the UI receives data from the service.
Future<void> start( Future<void> start(
Future<void> Function() entrypoint, Future<void> Function() entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleUIEvent, Future<void> Function(Map<String, dynamic>? data) handleUIEvent,
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
); );
/// Make sure that the UI event handler is registered without starting the isolate. /// Make sure that the UI event handler is registered without starting the isolate.
Future<void> attach( Future<void> attach(
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
); );
/// Return true if the background service is running. False if it's not. /// Return true if the background service is running. False if it's not.

View File

@ -1,5 +1,5 @@
import "package:moxlib/awaitabledatasender.dart"; import 'package:moxlib/awaitabledatasender.dart';
import "package:moxplatform_platform_interface/src/isolate.dart"; import 'package:moxplatform_platform_interface/src/isolate.dart';
class StubDataSender extends AwaitableDataSender { class StubDataSender extends AwaitableDataSender {
StubDataSender() : super(); StubDataSender() : super();
@ -9,24 +9,25 @@ class StubDataSender extends AwaitableDataSender {
} }
class StubIsolateHandler extends IsolateHandler { class StubIsolateHandler extends IsolateHandler {
final StubDataSender _sender;
StubIsolateHandler() : _sender = StubDataSender(); StubIsolateHandler() : _sender = StubDataSender();
final StubDataSender _sender;
@override @override
Future<void> attach( Future<void> attach(
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
) async { ) async {
print("STUB ATTACHED!!!!!!"); // ignore: avoid_print
print('STUB ATTACHED!!!!!!');
} }
@override @override
Future<void> start( Future<void> start(
Future<void> Function() entrypoint, Future<void> Function() entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleUIEvent, Future<void> Function(Map<String, dynamic>? data) handleUIEvent,
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
) async { ) async {
print("STUB STARTED!!!!!!"); // ignore: avoid_print
print('STUB STARTED!!!!!!');
} }
@override @override

View File

@ -1,4 +1,5 @@
/// Wrapper around platform-specific media scanning /// Wrapper around platform-specific media scanning
// ignore: one_member_abstracts
abstract class MediaScannerImplementation { abstract class MediaScannerImplementation {
/// Let the platform-specific media scanner scan the file at [path]. /// Let the platform-specific media scanner scan the file at [path].
void scanFile(String path); void scanFile(String path);

View File

@ -1,4 +1,4 @@
import "package:moxplatform_platform_interface/src/media.dart"; import 'package:moxplatform_platform_interface/src/media.dart';
class StubMediaScannerImplementation extends MediaScannerImplementation { class StubMediaScannerImplementation extends MediaScannerImplementation {
@override @override

View File

@ -1,4 +1,4 @@
import "package:moxplatform/types.dart"; import 'package:moxplatform/moxplatform.dart';
abstract class BackgroundService { abstract class BackgroundService {
/// Set the notification of the background service, if available /// Set the notification of the background service, if available
@ -12,6 +12,6 @@ abstract class BackgroundService {
/// data. /// data.
void init( void init(
Future<void> Function() entrypoint, Future<void> Function() entrypoint,
Future<void> Function(Map<String, dynamic>? data) handleEvent Future<void> Function(Map<String, dynamic>? data) handleEvent,
); );
} }

View File

@ -12,15 +12,16 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
moxlib:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.4
moxplatform: moxplatform:
hosted: https://git.polynom.me/api/packages/Moxxy/pub hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.11 version: 0.1.11
moxlib:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.1.4
plugin_platform_interface: 2.1.2 plugin_platform_interface: 2.1.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
very_good_analysis: 2.4.0