Лаба 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)),
|
||||
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: "Пучкина Анна Алексеевна!"),
|
||||
),
|
||||
)
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
},
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user