mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2025-12-22 01:20:46 +00:00
feat(app): Вынести инициализацию приложения за splash (#4)
Co-authored-by: PetrovY <y.petrov@friflex.com>
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
18
lib/features/splash/splash_screen.dart
Normal file
18
lib/features/splash/splash_screen.dart
Normal 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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user