feat(app): Вынести инициализацию приложения за splash (#4)

Co-authored-by: PetrovY <y.petrov@friflex.com>
This commit is contained in:
Yuri Petrov
2025-02-12 10:53:38 +03:00
committed by GitHub
parent 0a7452e1eb
commit af3b941711
18 changed files with 503 additions and 155 deletions

View File

@@ -16,7 +16,7 @@ class DebugScreen extends StatelessWidget {
padding: const EdgeInsets.all(16),
children: [
Text(
'Реализация SecureStorage: ${context.di.secureStorage.nameImpl}',
'Реализация SecureStorage: ${context.di.services.secureStorage.nameImpl}',
),
const SizedBox(height: 16),
Text(
@@ -82,14 +82,37 @@ class DebugScreen extends StatelessWidget {
),
const SizedBox(height: 16),
const Text('Тестовая иконка из assets'),
const SizedBox(height: 16),
Assets.icons.home.svg(),
ElevatedButton(
onPressed: () {
throw Exception(
'Тестовая ошибка Exception для отладки FlutterError',
);
},
child: const Text('Вызывать ошибку FlutterError'),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
await _callError();
},
child: const Text('Вызывать ошибку PlatformDispatcher'),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
await context.di.debugService.openDebugScreen(context);
},
child: const Text('Вызывать Экран отладки'),
),
],
),
),
);
}
Future<void> callError() async {
Future<void> _callError() async {
throw Exception('Тестовая ошибка Exception для отладки PlatformDispatcher');
}
}

View File

@@ -5,16 +5,42 @@ import 'package:flutter/material.dart';
/// {@endtemplate}
class ErrorScreen extends StatelessWidget {
/// {@macro ErrorScreen}
const ErrorScreen({super.key});
const ErrorScreen({
super.key,
required this.error,
required this.stackTrace,
this.onRetry,
});
final Object? error;
final StackTrace? stackTrace;
final VoidCallback? onRetry;
@override
Widget build(BuildContext context) {
return const MaterialApp(
return MaterialApp(
home: Scaffold(
body: Center(
child: Text(
'Что-то пошло не так, попробуйте перезагрузить приложение',
textAlign: TextAlign.center,
body: SafeArea(
child: Center(
child: ListView(
padding: const EdgeInsets.all(16),
children: [
const SizedBox(height: 16),
ElevatedButton(
onPressed: onRetry,
child: const Text('Перезагрузить приложение'),
),
const SizedBox(height: 16),
Text(
'''
Что-то пошло не так, попробуйте перезагрузить приложение
error: $error
stackTrace: $stackTrace
''',
textAlign: TextAlign.center,
),
],
),
),
),
),

View File

@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:friflex_starter/gen/assets.gen.dart';
/// {@template SplashScreen}
/// Экран загрузки приложения.
/// {@endtemplate}
class SplashScreen extends StatelessWidget {
/// {@macro SplashScreen}
const SplashScreen({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: Assets.lottie.splash.lottie(),
);
}
}