mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2025-12-22 09:30:45 +00:00
* feat(app): Добавить пример со Scope * fix scope * feat: добавить скоуп с внутренней зависимостью от репозитория (#6) Co-authored-by: Artem Barkalov <artembark@gmail.com> * feat: исправить обалсть видимости ProfileScope * feat: добавить фикс namespace плагинов --------- Co-authored-by: PetrovY <y.petrov@friflex.com> Co-authored-by: Artem Barkalov <artembark@gmail.com>
49 lines
1.7 KiB
Dart
49 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:friflex_starter/app/app_context_ext.dart';
|
|
import 'package:friflex_starter/features/profile/domain/bloc/profile_bloc.dart';
|
|
|
|
// Класс экрана, где мы инициализируем ProfileBloc
|
|
// и вызываем событие ProfileFetchProfileEvent
|
|
class ProfileScreen extends StatelessWidget {
|
|
const ProfileScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final profileRepository = context.di.repositories.profileRepository;
|
|
// Здесь мы инициализируем ProfileBloc
|
|
// и вызываем событие ProfileFetchProfileEvent
|
|
// Или любые другие события, которые вам нужны
|
|
return BlocProvider(
|
|
create: (context) => ProfileBloc(profileRepository)
|
|
..add(const ProfileFetchProfileEvent(id: '1')),
|
|
child: const _ProfileScreenView(),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Виджет, который отображает UI экрана
|
|
class _ProfileScreenView extends StatelessWidget {
|
|
const _ProfileScreenView();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Profile'),
|
|
),
|
|
body: Center(
|
|
child: BlocBuilder<ProfileBloc, ProfileState>(
|
|
builder: (context, state) {
|
|
return switch (state) {
|
|
ProfileSuccessState() => Text('Data: ${state.props.first}'),
|
|
ProfileErrorState() => Text('Error: ${state.message}'),
|
|
_ => const CircularProgressIndicator(),
|
|
};
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|