Лаба 6,подправила поиск у рика и морти

This commit is contained in:
a.puchkina 2024-10-16 20:58:22 +04:00
parent 04b7f0ca98
commit 700a772c26
3 changed files with 7 additions and 9 deletions

View File

@ -21,12 +21,12 @@ class MyApp extends StatelessWidget {
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF7BA05B)),
useMaterial3: true,
),
home: RepositoryProvider<PotterRepository>(
home: RepositoryProvider<RickandMortyRepository>(
lazy: true,
create: (_) => PotterRepository(),
create: (_) => RickandMortyRepository(),
child: BlocProvider<HomeBloc>(
lazy: false,
create: (context) => HomeBloc(context.read<PotterRepository>()),
create: (context) => HomeBloc(context.read<RickandMortyRepository>()),
child: const MyHomePage(title: "Пучкина Анна Алексеевна!"),
),
)

View File

@ -5,8 +5,8 @@ import 'package:app/repositories/rick&morty_repositoty.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class HomeBloc extends Bloc<HomeEvent, HomeState> {
//final RickandMortyRepository repo;
final PotterRepository repo;
final RickandMortyRepository repo;
//final PotterRepository repo;
HomeBloc(this.repo) : super(const HomeState()) {
on<HomeLoadDataEvent>(_onLoadData);

View File

@ -20,7 +20,6 @@ class RickandMortyRepository extends ApiInterface {
OnErrorCallback? onError,
String? q,
int page = 1,
int pageSize= 25,
}) async {
try {
const String url = '$_baseUrl/api/character';
@ -28,9 +27,8 @@ class RickandMortyRepository extends ApiInterface {
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
url,
queryParameters: {
'filter[name_cont]': q,
'page[number]' : page,
'page[size]' : pageSize
'name': q,
'page' : page,
},
);