better linting

This commit is contained in:
Mguy13 2023-01-01 13:04:22 +01:00
parent c7324a6b19
commit aa31a79d20
26 changed files with 163 additions and 131 deletions

View file

@ -25,7 +25,7 @@ class McgRouter {
path: Routes.imageCarousel.routePath,
name: Routes.imageCarousel.routeName,
builder: (context, state) => ImageCarouselView(
imageCarouselViewArguments: state.extra as ImageCarouselViewArguments,
imageCarouselViewArguments: state.extra! as ImageCarouselViewArguments,
),
),
],

View file

@ -17,11 +17,11 @@ enum Routes {
}
class RoutesInfo {
final String routePath;
final String routeName;
const RoutesInfo({
required this.routePath,
required this.routeName,
});
final String routePath;
final String routeName;
}

View file

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
abstract class ConstColours {
/// Smoke Gray => a neutral grey with neutral warmth/cold
static const galleryBackgroundColour = Color.fromRGBO(127, 127, 125, 1.0);
static const galleryBackgroundColour = Color.fromRGBO(127, 127, 125, 1);
static const red = Colors.red;
static const white = Colors.white;

View file

@ -1,6 +1,7 @@
import 'package:dio/dio.dart';
extension ResponseExtensions on Response {
/// Extensions on [Dio]'s [Response].
extension ResponseExtensions<T> on Response<T> {
/// Shorthand for getting response's successful state.
bool get isSuccessful => (data as Map)['response'];
bool get isSuccessful => (data! as Map<String, dynamic>)['response'] as bool;
}

View file

@ -1,3 +1,4 @@
/// String extensions
extension StringExtensions on String {
/// Returns true if given word contains atleast all the characters in [targetChars], and `false` otherwise
///
@ -6,9 +7,9 @@ extension StringExtensions on String {
required String targetChars,
bool ignoreCase = true,
}) {
final Set<String> characterSet = ignoreCase
? Set.from(targetChars.toLowerCase().split(''))
: Set.from(targetChars.split(''));
final characterSet = ignoreCase
? Set<String>.from(targetChars.toLowerCase().split(''))
: Set<String>.from(targetChars.split(''));
for (final testChar in ignoreCase ? toLowerCase().split('') : split('')) {
characterSet.remove(testChar);
if (characterSet.isEmpty) return true;

View file

@ -25,7 +25,7 @@ class AppLifecycleService with WidgetsBindingObserver {
late final StreamController<AppLifecycleState> _lifecycleStateStreamController =
StreamController.broadcast();
final Map<String, StreamSubscription> _appLifecycleSubscriptions = {};
final Map<String, StreamSubscription<dynamic>> _appLifecycleSubscriptions = {};
AppLifecycleState? _appLifeCycleState;
AppLifecycleState? get appLifeCycleState => _appLifeCycleState;

View file

@ -64,7 +64,7 @@ class ConnectionsService {
static ConnectionsService get locate => Locator.locate();
}
extension _connectionStatusEmojiExtension on InternetConnectionStatus {
extension _ConnectionStatusEmojiExtension on InternetConnectionStatus {
String get nameWithIcon {
switch (this) {
case InternetConnectionStatus.connected:
@ -75,7 +75,7 @@ extension _connectionStatusEmojiExtension on InternetConnectionStatus {
}
}
extension _connectivityEmojiExtension on ConnectivityResult {
extension _ConnectivityEmojiExtension on ConnectivityResult {
String get nameWithIcon {
switch (this) {
case ConnectivityResult.bluetooth:

View file

@ -29,7 +29,7 @@ class LocalStorageService {
}
void updateFavourite({
required index,
required int index,
required bool newValue,
}) {
try {

View file

@ -15,8 +15,8 @@ class LoggingService {
useHistory: false,
),
logger: TalkerLogger(
formater:
!Platform.isIOS ? const ColoredLoggerFormatter() : const ExtendedLoggerFormatter()),
formater: !Platform.isIOS ? const ColoredLoggerFormatter() : const ExtendedLoggerFormatter(),
),
loggerSettings: TalkerLoggerSettings(
enableColors: !Platform.isIOS,
),
@ -49,11 +49,10 @@ class LoggingService {
TalkerDioLogger(
talker: Talker(
logger: TalkerLogger(
formater: !Platform.isIOS
? const ColoredLoggerFormatter()
: const ExtendedLoggerFormatter()),
formater:
!Platform.isIOS ? const ColoredLoggerFormatter() : const ExtendedLoggerFormatter(),
),
settings: TalkerSettings(
useConsoleLogs: true,
useHistory: false,
),
loggerSettings: TalkerLoggerSettings(
@ -63,7 +62,6 @@ class LoggingService {
settings: const TalkerDioLoggerSettings(
printRequestHeaders: true,
printResponseHeaders: true,
printResponseMessage: true,
),
),
);

View file

@ -24,8 +24,9 @@ class OverlayService {
//todo(mehul): Fix and not ignore Overlay building while Widget building error.
} on FlutterError catch (_) {}
_loggingService.info('Overlay inserted with tag: $tag');
} else
} else {
_loggingService.info('Overlay with tag: $tag, NOT inserted');
}
}
void removeOverlayEntry({
@ -37,10 +38,12 @@ class OverlayService {
_overlayEntryMap[tag.hashCode]?.remove();
_overlayEntryMap.remove(tag.hashCode);
_loggingService.info('Overlay removed with tag: $tag');
} else
} else {
_loggingService.info('Overlay with tag: $tag already mounted OR not found. Skipped');
} else
}
} else {
_loggingService.info('Overlay with tag: $tag already exists. Skipped');
}
}
void dispose() {

View file

@ -4,19 +4,19 @@ import 'dart:ui';
/// A simple Mutex implementation using a [Completer].
class Mutex {
final _completerQueue = Queue<Completer>();
final _completerQueue = Queue<Completer<void>>();
/// Runs the given [run] function-block in a thread-safe/blocked zone. A convenient `unlock()`
/// is provided, which can be called anywhere to signal re-entry.
FutureOr<T> lockAndRun<T>({
required FutureOr<T> Function(VoidCallback unlock) run,
}) async {
final completer = Completer();
final completer = Completer<void>();
_completerQueue.add(completer);
if (_completerQueue.first != completer) {
await _completerQueue.removeFirst().future;
}
final value = await run(() => completer.complete());
final value = await run(completer.complete);
return value;
}

View file

@ -17,7 +17,7 @@ class ErrorPageView extends StatelessWidget {
child: Column(
children: [
Text(Strings.current.errorPageMessage),
const Gap(16),
Gap.size16,
],
),
);

View file

@ -1,8 +1,12 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
/// Const evenly-sized gap.
class Gap extends LeafRenderObjectWidget {
const Gap(this.size, {Key? key}) : super(key: key);
const Gap(
this.size, {
super.key,
});
final double size;
@ -58,13 +62,14 @@ class RenderGap extends RenderBox {
}
}
/// Animates [Gap] insertion.
class AnimatedGap extends StatefulWidget {
const AnimatedGap(
this.gap, {
Key? key,
this.duration = const Duration(milliseconds: 200),
this.curve = Curves.easeInOut,
}) : super(key: key);
super.key,
});
final Duration duration;
final double gap;
@ -107,10 +112,10 @@ class _AnimatedGapState extends State<AnimatedGap> with SingleTickerProviderStat
class AnimatedSliverGap extends StatefulWidget {
const AnimatedSliverGap(
this.gap, {
Key? key,
this.duration = const Duration(milliseconds: 200),
this.curve = Curves.easeInOut,
}) : super(key: key);
super.key,
});
final Duration duration;
final double gap;

View file

@ -8,10 +8,13 @@ class MultiValueListenableBuilder extends StatelessWidget {
required this.builder,
this.child,
super.key,
}) : assert(valueListenables.length != 0);
}) : assert(
valueListenables.length != 0,
'Attached valueListenables must not be empty',
);
/// List of [ValueListenable]s to be listened to.
final List<ValueListenable> valueListenables;
final List<ValueListenable<dynamic>> valueListenables;
/// The builder function to be called when value of any of the [ValueListenable] changes.
/// The order of values list will be same as [valueListenables] list.