diff --git a/lib/main.dart b/lib/main.dart index ac75a1c..bdf80a1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,8 +17,11 @@ class MyApp extends StatelessWidget { title: 'University App', theme: ThemeData( primarySwatch: Colors.blue, + scaffoldBackgroundColor: Colors.white, // Устанавливаем белый фон + ), + home: ScaffoldMessenger( + child: UniversityScreen(), ), - home: UniversityScreen(), ); } } @@ -59,6 +62,7 @@ class _UniversityScreenState extends State { theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.orangeAccent), useMaterial3: true, + scaffoldBackgroundColor: Colors.white, // Устанавливаем белый фон ), home: RepositoryProvider( lazy: true, @@ -66,9 +70,11 @@ class _UniversityScreenState extends State { child: BlocProvider( lazy: false, create: (context) => HomeBloc(context.read()), - child: const MyHomePage(), + child: Scaffold( + body: const MyHomePage(), + ), ), - ) + ), ); } -} +} \ No newline at end of file diff --git a/lib/presentation/home_page/home_page.dart b/lib/presentation/home_page/home_page.dart index a8f68c5..c9d4657 100644 --- a/lib/presentation/home_page/home_page.dart +++ b/lib/presentation/home_page/home_page.dart @@ -35,7 +35,7 @@ class _MyHomePageState extends State { } void _onNextPageListener(){ - if(scrollController.offset > scrollController.position.maxScrollExtent) { + if(scrollController.offset >= scrollController.position.maxScrollExtent) { final bloc = context.read(); if(!bloc.state.isPaginationLoading) { bloc.add(HomeLoadDataEvent ( @@ -75,6 +75,7 @@ class _MyHomePageState extends State { child: RefreshIndicator( onRefresh: _onRefresh, child: ListView.builder( + controller: scrollController, padding: EdgeInsets.zero, itemCount: state.data?.data?.length ?? 0, itemBuilder: (context, index) { @@ -89,8 +90,13 @@ class _MyHomePageState extends State { }, ), ), - ) + ), ), + BlocBuilder( + builder: (context, state) => state.isPaginationLoading + ? const CircularProgressIndicator() + : const SizedBox.shrink(), + ) ], ), ); diff --git a/lib/repo/potter_repo.dart b/lib/repo/potter_repo.dart index fb094de..21cc9c5 100644 --- a/lib/repo/potter_repo.dart +++ b/lib/repo/potter_repo.dart @@ -18,14 +18,18 @@ class PotterRepo extends ApiInterface { @override Future loadData( - {OnErrorCallback? onError, String? q, int page = 1, int pageSize = 25}) async { + {OnErrorCallback? onError, + String? q, + int page = 1, + int pageSize = 25 + }) async { try { const String url = '$_baseUrl/v1/characters'; final Response response = await _dio.get>( url, queryParameters: { - 'filter[name_count]': q, + 'filter[name_cont]': q, 'page[number]': page, 'page[size]': pageSize, },