Лаба 6,подправила поиск у рика и морти
This commit is contained in:
parent
04b7f0ca98
commit
700a772c26
@ -21,12 +21,12 @@ class MyApp extends StatelessWidget {
|
|||||||
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF7BA05B)),
|
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF7BA05B)),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: RepositoryProvider<PotterRepository>(
|
home: RepositoryProvider<RickandMortyRepository>(
|
||||||
lazy: true,
|
lazy: true,
|
||||||
create: (_) => PotterRepository(),
|
create: (_) => RickandMortyRepository(),
|
||||||
child: BlocProvider<HomeBloc>(
|
child: BlocProvider<HomeBloc>(
|
||||||
lazy: false,
|
lazy: false,
|
||||||
create: (context) => HomeBloc(context.read<PotterRepository>()),
|
create: (context) => HomeBloc(context.read<RickandMortyRepository>()),
|
||||||
child: const MyHomePage(title: "Пучкина Анна Алексеевна!"),
|
child: const MyHomePage(title: "Пучкина Анна Алексеевна!"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -5,8 +5,8 @@ import 'package:app/repositories/rick&morty_repositoty.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||||
//final RickandMortyRepository repo;
|
final RickandMortyRepository repo;
|
||||||
final PotterRepository repo;
|
//final PotterRepository repo;
|
||||||
|
|
||||||
HomeBloc(this.repo) : super(const HomeState()) {
|
HomeBloc(this.repo) : super(const HomeState()) {
|
||||||
on<HomeLoadDataEvent>(_onLoadData);
|
on<HomeLoadDataEvent>(_onLoadData);
|
||||||
|
@ -20,7 +20,6 @@ class RickandMortyRepository extends ApiInterface {
|
|||||||
OnErrorCallback? onError,
|
OnErrorCallback? onError,
|
||||||
String? q,
|
String? q,
|
||||||
int page = 1,
|
int page = 1,
|
||||||
int pageSize= 25,
|
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
const String url = '$_baseUrl/api/character';
|
const String url = '$_baseUrl/api/character';
|
||||||
@ -28,9 +27,8 @@ class RickandMortyRepository extends ApiInterface {
|
|||||||
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
|
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
|
||||||
url,
|
url,
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'filter[name_cont]': q,
|
'name': q,
|
||||||
'page[number]' : page,
|
'page' : page,
|
||||||
'page[size]' : pageSize
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user