diff --git a/examples/shop_app_example/lib/features/products/view/products_screen.dart b/examples/shop_app_example/lib/features/products/view/products_screen.dart index 5ab3ed10..7c207555 100644 --- a/examples/shop_app_example/lib/features/products/view/products_screen.dart +++ b/examples/shop_app_example/lib/features/products/view/products_screen.dart @@ -47,7 +47,7 @@ class _ProductsScreenState extends State { ), actions: [ _OpenLogsButton( - onPressed: () => _openTalekrScreen(context), + onPressed: () => _openTalkerScreen(context), ), ], ), @@ -99,7 +99,7 @@ class _ProductsScreenState extends State { ); } - void _openTalekrScreen(BuildContext context) => + void _openTalkerScreen(BuildContext context) => Navigator.pushNamed(context, Routes.talker); void _openProductScreen(BuildContext context, List products, int i) { diff --git a/examples/shop_app_example/lib/main.dart b/examples/shop_app_example/lib/main.dart index 9b4e9811..de50bf7d 100644 --- a/examples/shop_app_example/lib/main.dart +++ b/examples/shop_app_example/lib/main.dart @@ -20,21 +20,52 @@ void main() { runZonedGuarded(() async { WidgetsFlutterBinding.ensureInitialized(); await _initFirebase(); - _initTalker(); - _registerRepositories(); - Bloc.observer = TalkerBlocObserver( - talker: DI(), - settings: const TalkerBlocLoggerSettings( - printCreations: true, - printClosings: true, - ), - ); + _initDependencies(); runApp(const MyApp()); }, (Object error, StackTrace stack) { DI().handle(error, stack, 'Uncaught app exception'); }); } +void _initDependencies() { + final talker = TalkerFlutter.init( + settings: TalkerSettings( + colors: { + TalkerLogType.verbose: AnsiPen()..yellow(), + }, + ), + ); + DI.registerSingleton(talker); + talker.verbose('Talker initialization completed'); + + final talkerDioLogger = TalkerDioLogger( + talker: talker, + settings: const TalkerDioLoggerSettings( + printRequestHeaders: true, + printResponseHeaders: false, + printRequestData: true, + printResponseData: false, + ), + ); + + final dio = Dio(); + dio.interceptors.add(talkerDioLogger); + + DI.registerSingleton( + ProductsRepository(dio: dio), + ); + talker.info('Repositories initialization completed'); + + Bloc.observer = TalkerBlocObserver( + talker: talker, + settings: const TalkerBlocLoggerSettings( + printCreations: false, + printClosings: false, + printStateFullData: false, + ), + ); +} + Future _initFirebase() async { if (kIsWeb) { await Firebase.initializeApp( @@ -46,7 +77,7 @@ Future _initFirebase() async { } class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override Widget build(BuildContext context) { @@ -71,39 +102,3 @@ class MyApp extends StatelessWidget { ); } } - -void _initTalker() { - final talker = TalkerFlutter.init(); - DI.registerSingleton(talker); - talker.verbose('Talker initialization completed'); - - /// This logic is just for example here - if (!DI.isRegistered()) { - DI.registerSingleton(talker); - } else { - talker.warning('Trying to re-register an object in GetIt'); - } - - /// Dio logger initialization - final talkerDioLogger = TalkerDioLogger( - talker: DI(), - settings: const TalkerDioLoggerSettings( - printRequestHeaders: true, - printResponseHeaders: true, - printRequestData: true, - printResponseData: true, - ), - ); - - DI.registerSingleton(talkerDioLogger); -} - -void _registerRepositories() { - final dio = Dio(); - dio.interceptors.add(DI()); - - DI.registerSingleton( - ProductsRepository(dio: dio), - ); - DI().info('Repositories initialization completed'); -} diff --git a/examples/shop_app_example/pubspec.lock b/examples/shop_app_example/pubspec.lock index a3a3261e..f8c4703d 100644 --- a/examples/shop_app_example/pubspec.lock +++ b/examples/shop_app_example/pubspec.lock @@ -430,7 +430,7 @@ packages: source: hosted version: "1.2.0" talker: - dependency: "direct main" + dependency: "direct overridden" description: path: "../../packages/talker" relative: true diff --git a/examples/shop_app_example/pubspec.yaml b/examples/shop_app_example/pubspec.yaml index 4829e099..21820091 100644 --- a/examples/shop_app_example/pubspec.yaml +++ b/examples/shop_app_example/pubspec.yaml @@ -9,10 +9,10 @@ dependencies: flutter: sdk: flutter - talker: ^3.2.0 - talker_flutter: ^3.6.0 - talker_dio_logger: ^2.4.0 - talker_bloc_logger: ^2.4.0 + talker_flutter: ^4.0.0 + talker_dio_logger: ^4.0.0 + talker_bloc_logger: ^4.0.0 + get_it: ^7.6.7 flutter_bloc: ^8.1.3 equatable: ^2.0.5