mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2025-12-22 17:40:45 +00:00
Compare commits
5 Commits
3.38.1
...
feat/перен
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4260c7cc65 | ||
|
|
2595692107 | ||
|
|
c86b4cc0bc | ||
|
|
d46c829959 | ||
|
|
84e5f5e869 |
@@ -12,6 +12,7 @@ import 'package:friflex_starter/features/update/domain/state/cubit/update_cubit.
|
|||||||
import 'package:friflex_starter/features/update/update_routes.dart';
|
import 'package:friflex_starter/features/update/update_routes.dart';
|
||||||
import 'package:friflex_starter/l10n/gen/app_localizations.dart';
|
import 'package:friflex_starter/l10n/gen/app_localizations.dart';
|
||||||
import 'package:friflex_starter/l10n/localization_notifier.dart';
|
import 'package:friflex_starter/l10n/localization_notifier.dart';
|
||||||
|
import 'package:friflex_starter/router/app_router.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
/// {@template app}
|
/// {@template app}
|
||||||
@@ -26,10 +27,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
class App extends StatefulWidget {
|
class App extends StatefulWidget {
|
||||||
/// {@macro app}
|
/// {@macro app}
|
||||||
const App({required this.router, required this.initDependencies, super.key});
|
const App({required this.initDependencies, super.key});
|
||||||
|
|
||||||
/// Роутер приложения для навигации между экранами
|
|
||||||
final GoRouter router;
|
|
||||||
|
|
||||||
/// Функция для инициализации зависимостей приложения
|
/// Функция для инициализации зависимостей приложения
|
||||||
/// Возвращает Future с контейнером зависимостей
|
/// Возвращает Future с контейнером зависимостей
|
||||||
@@ -78,7 +76,7 @@ class _AppState extends State<App> {
|
|||||||
// Если данные получены и не равны null, то отображаем внутренний виджет приложения
|
// Если данные получены и не равны null, то отображаем внутренний виджет приложения
|
||||||
// Иначе отображаем экран ошибки
|
// Иначе отображаем экран ошибки
|
||||||
(snapshot.hasData && snapshot.data != null)
|
(snapshot.hasData && snapshot.data != null)
|
||||||
? _App(router: widget.router, diContainer: snapshot.data!)
|
? _AppInternal(diContainer: snapshot.data!)
|
||||||
: ErrorScreen(
|
: ErrorScreen(
|
||||||
error: snapshot.error,
|
error: snapshot.error,
|
||||||
stackTrace: snapshot.stackTrace,
|
stackTrace: snapshot.stackTrace,
|
||||||
@@ -106,20 +104,45 @@ class _AppState extends State<App> {
|
|||||||
///
|
///
|
||||||
/// Настраивает MaterialApp с роутером, темами и локализацией.
|
/// Настраивает MaterialApp с роутером, темами и локализацией.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
class _App extends StatelessWidget {
|
class _AppInternal extends StatefulWidget {
|
||||||
/// {@macro app_internal}
|
/// {@macro app_internal}
|
||||||
const _App({required this.router, required this.diContainer});
|
const _AppInternal({
|
||||||
|
required this.diContainer,
|
||||||
/// Роутер приложения для навигации
|
@visibleForTesting this.mockRouter, // ignore: unused_element_parameter
|
||||||
final GoRouter router;
|
});
|
||||||
|
|
||||||
/// Контейнер зависимостей
|
/// Контейнер зависимостей
|
||||||
final DiContainer diContainer;
|
final DiContainer diContainer;
|
||||||
|
|
||||||
|
/// Роутер приложения для навигации для тестирования
|
||||||
|
final GoRouter? mockRouter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_AppInternal> createState() => _AppInternalState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AppInternalState extends State<_AppInternal> {
|
||||||
|
/// Роутер приложения для навигации
|
||||||
|
late final GoRouter router;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
router =
|
||||||
|
widget.mockRouter ??
|
||||||
|
AppRouter.createRouter(widget.diContainer.debugService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
router.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DependsProviders(
|
return DependsProviders(
|
||||||
diContainer: diContainer,
|
diContainer: widget.diContainer,
|
||||||
child: BlocConsumer<UpdateCubit, UpdateState>(
|
child: BlocConsumer<UpdateCubit, UpdateState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is UpdateSuccessState &&
|
if (state is UpdateSuccessState &&
|
||||||
|
|||||||
@@ -65,14 +65,10 @@ class AppRunner {
|
|||||||
// Инициализация метода обработки ошибок
|
// Инициализация метода обработки ошибок
|
||||||
_initErrorHandlers(_debugService);
|
_initErrorHandlers(_debugService);
|
||||||
|
|
||||||
// Инициализация роутера
|
|
||||||
router = AppRouter.createRouter(_debugService);
|
|
||||||
|
|
||||||
// throw Exception('Test error');
|
// throw Exception('Test error');
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
App(
|
App(
|
||||||
router: router,
|
|
||||||
initDependencies: () {
|
initDependencies: () {
|
||||||
return _initDependencies(
|
return _initDependencies(
|
||||||
debugService: _debugService,
|
debugService: _debugService,
|
||||||
|
|||||||
Reference in New Issue
Block a user