refactoring

security update
This commit is contained in:
Mguy13 2022-12-25 22:17:59 +01:00
parent 1747ab0245
commit 78fe9e7b09
39 changed files with 289 additions and 132 deletions

View file

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
@ -49,5 +50,11 @@ abstract class AppSetup {
static void Function(Object error, StackTrace stackTrace) get onUncaughtException => (
error,
stackTrace,
) {};
) {
log(
'Error occurred during app startup',
error: error,
stackTrace: stackTrace,
);
};
}

View file

@ -17,7 +17,7 @@ abstract class BaseViewModel<T extends Object?> extends ChangeNotifier {
final ValueNotifier<ViewModelState> _state = ValueNotifier(ViewModelState.isInitialising);
ValueListenable<ViewModelState> get state => _state;
final LoggingService _loggingService = LoggingService.locate;
final LoggingService log = LoggingService.locate;
String? _errorMessage;
String get errorMessage => _errorMessage ?? strings.somethingWentWrong;
@ -27,7 +27,7 @@ abstract class BaseViewModel<T extends Object?> extends ChangeNotifier {
_mounted = mounted;
_isInitialised.value = true;
_state.value = ViewModelState.isInitialised;
_loggingService.successfulInit(location: runtimeType.toString());
log.successfulInit(location: runtimeType.toString());
}
void setBusy(bool isBusy) {
@ -55,7 +55,7 @@ abstract class BaseViewModel<T extends Object?> extends ChangeNotifier {
@override
void dispose() {
super.dispose();
_loggingService.successfulDispose(location: runtimeType.toString());
log.successfulDispose(location: runtimeType.toString());
}
late final bool Function() _mounted;

View file

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:mc_gallery/features/home/views/gallery/gallery_view.dart';
import 'package:mc_gallery/features/home/views/image_carousel/image_carousel_view.dart';
import '/features/home/views/gallery/gallery_view.dart';
import '/features/home/views/image_carousel/image_carousel_view.dart';
import '../../views/error_page_view.dart';
import 'routes.dart';
@ -15,7 +15,6 @@ class McgRouter {
key: state.pageKey,
child: ErrorPageView(error: state.error),
),
//todo(mehul): Add Redirect
routes: [
GoRoute(
path: Routes.home.routePath,

View file

@ -1,6 +1,6 @@
enum Routes {
home(RoutesInfo(
routePath: '/gallery',
routePath: '/',
routeName: 'Home',
)),
imageCarousel(RoutesInfo(