PIbd-31_Afanasev.S.S._Mobil.../lib/main.dart
2024-11-29 16:08:55 +04:00

41 lines
1.4 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test_app/presentation/home_page/bloc/bloc.dart';
import 'data/repositories/characters_repository.dart';
import 'presentation/home_page/home_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
useMaterial3: true,
),
home: RepositoryProvider<AgentsRepository>( //даём нашему репозиторию доступ
lazy: true, //ленивое создание объекта
create: (_) => AgentsRepository(),
child: BlocProvider<HomeBloc>( //даём доступ Bloc для нашей страницы
lazy: false,
create: (context) => HomeBloc(context.read<AgentsRepository>()), //в конструктор нашего Блока передаём репозиторий с нашей апи, то есть у нас появляется доступ по дереву к апи
child: const MyHomePage(title: 'Агенты Valorant'),
),
),
);
}
}