From 0cd3e3954f10fca6330794cde8e1a274b4d7328d Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Thu, 2 May 2024 12:49:46 +0400 Subject: [PATCH] Update analysis options and localization.dart files, refactor Controller class, and fix linting issues in various files --- analysis_options.yaml | 3 --- example/lib/src/common/controller/controller.dart | 7 +++++-- example/lib/src/common/localization/localization.dart | 2 +- example/lib/src/common/widget/app.dart | 2 +- lib/src/model/channel_push.dart | 2 +- lib/src/model/event.dart | 2 +- lib/src/subscription/subscription_state.dart | 3 +++ lib/src/transport/ws_protobuf_transport.dart | 2 ++ 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 907ca29..218404e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -76,7 +76,6 @@ linter: avoid_js_rounded_ints: true avoid_print: true avoid_renaming_method_parameters: true - avoid_returning_null_for_future: true avoid_returning_null_for_void: true avoid_single_cascade_in_expression_statements: true avoid_slow_async_io: true @@ -140,7 +139,6 @@ linter: # Pedantic 1.9.0 always_declare_return_types: true - always_require_non_null_named_parameters: true annotate_overrides: true avoid_empty_else: true avoid_init_to_null: true @@ -204,7 +202,6 @@ linter: prefer_mixin: true use_setters_to_change_properties: true avoid_setters_without_getters: true - avoid_returning_null: true avoid_returning_this: true type_annotate_public_apis: true avoid_types_on_closure_parameters: true diff --git a/example/lib/src/common/controller/controller.dart b/example/lib/src/common/controller/controller.dart index 731fc37..1864cbc 100644 --- a/example/lib/src/common/controller/controller.dart +++ b/example/lib/src/common/controller/controller.dart @@ -26,14 +26,16 @@ abstract interface class IControllerObserver { void onDispose(IController controller); /// Called on any state change in the controller. - void onStateChanged(IController controller, Object prevState, Object nextState); + void onStateChanged( + IController controller, Object prevState, Object nextState); /// Called on any error in the controller. void onError(IController controller, Object error, StackTrace stackTrace); } -/// {@template controller} +/// {@macro controller} abstract base class Controller with ChangeNotifier implements IController { + /// {@macro controller} Controller() { runZonedGuarded( () => Controller.observer?.onCreate(this), @@ -44,6 +46,7 @@ abstract base class Controller with ChangeNotifier implements IController { /// Controller observer static IControllerObserver? observer; + /// Whether the controller is disposed. bool get isDisposed => _$isDisposed; bool _$isDisposed = false; diff --git a/example/lib/src/common/localization/localization.dart b/example/lib/src/common/localization/localization.dart index 1eada77..80600fc 100644 --- a/example/lib/src/common/localization/localization.dart +++ b/example/lib/src/common/localization/localization.dart @@ -31,7 +31,7 @@ final class Localization extends generated.GeneratedLocalization { /// Get language by code. static ({String name, String nativeName})? getLanguageByCode(String code) => switch (_isoLangs[code]) { - (:String name, :String nativeName) => ( + (String name, String nativeName) => ( name: name, nativeName: nativeName ), diff --git a/example/lib/src/common/widget/app.dart b/example/lib/src/common/widget/app.dart index ff27bb4..59046b9 100644 --- a/example/lib/src/common/widget/app.dart +++ b/example/lib/src/common/widget/app.dart @@ -41,7 +41,7 @@ class App extends StatelessWidget { builder: (context, child) => MediaQuery( data: MediaQuery.of(context).copyWith( /* textScaler: TextScaler.noScaling, */ - textScaleFactor: 1, + textScaler: const TextScaler.linear(1), ), child: WindowScope( /* title: Localization.of(context).title, */ diff --git a/lib/src/model/channel_push.dart b/lib/src/model/channel_push.dart index 29e8208..5fb7f44 100644 --- a/lib/src/model/channel_push.dart +++ b/lib/src/model/channel_push.dart @@ -8,7 +8,7 @@ import 'package:spinify/src/model/event.dart'; /// {@subCategory Push} @immutable abstract base class SpinifyChannelPush extends SpinifyEvent { - /// {@template spinify_channel_push} + /// {@macro spinify_channel_push} const SpinifyChannelPush({ required super.timestamp, required this.channel, diff --git a/lib/src/model/event.dart b/lib/src/model/event.dart index 08fca41..837e025 100644 --- a/lib/src/model/event.dart +++ b/lib/src/model/event.dart @@ -6,7 +6,7 @@ import 'package:meta/meta.dart'; /// {@category Event} @immutable abstract base class SpinifyEvent implements Comparable { - /// {@template spinify_event} + /// {@macro spinify_event} const SpinifyEvent({ required this.timestamp, }); diff --git a/lib/src/subscription/subscription_state.dart b/lib/src/subscription/subscription_state.dart index bf1113b..31a1f66 100644 --- a/lib/src/subscription/subscription_state.dart +++ b/lib/src/subscription/subscription_state.dart @@ -55,6 +55,7 @@ sealed class SpinifySubscriptionState extends _$SpinifySubscriptionStateBase { /// {@category Entity} final class SpinifySubscriptionState$Unsubscribed extends SpinifySubscriptionState { + /// {@macro subscription_state} SpinifySubscriptionState$Unsubscribed({ required this.code, required this.reason, @@ -119,6 +120,7 @@ final class SpinifySubscriptionState$Unsubscribed /// {@category Entity} final class SpinifySubscriptionState$Subscribing extends SpinifySubscriptionState { + /// {@macro subscription_state} SpinifySubscriptionState$Subscribing({ DateTime? timestamp, super.since, @@ -168,6 +170,7 @@ final class SpinifySubscriptionState$Subscribing /// {@category Entity} final class SpinifySubscriptionState$Subscribed extends SpinifySubscriptionState { + /// {@macro subscription_state} SpinifySubscriptionState$Subscribed({ DateTime? timestamp, super.since, diff --git a/lib/src/transport/ws_protobuf_transport.dart b/lib/src/transport/ws_protobuf_transport.dart index d774702..9d1c28b 100644 --- a/lib/src/transport/ws_protobuf_transport.dart +++ b/lib/src/transport/ws_protobuf_transport.dart @@ -979,6 +979,7 @@ base mixin SpinifyWSPBPingPongMixin on SpinifyWSPBTransportBase { final List _emptyPublicationsList = List.empty(growable: false); +/// Decode protobuf messages to Spinify models. @internal SpinifyPublication Function(pb.Publication publication) $publicationDecode( String channel, @@ -995,6 +996,7 @@ SpinifyPublication Function(pb.Publication publication) $publicationDecode( ); } +/// Decode protobuf client info to Spinify client info. @internal SpinifyClientInfo $decodeClientInfo(pb.ClientInfo info) => SpinifyClientInfo( client: info.client,