bloc_pagination 0.1.1 copy "bloc_pagination: ^0.1.1" to clipboard
bloc_pagination: ^0.1.1 copied to clipboard

Flutter package provide easiest way to handle pagination pages using flutter_bloc state management

BlocPagination #

All Contributors Actions Status pub package

Installing #

In your pubspec.yaml

dependencies:
  bloc_pagination: //add latest version
import 'package:bloc_pagination/bloc_pagination.dart';

Basic Usage #

class MyBloc extends PaginationBloc {
  @override
  Future<ListResponse<PaginationModel>> findAll(int page,
      {AbstractQueryParameters? queryParameters}) async {
          /// your data source
    return readRepository.findAll(page, params: queryParameters);
  }
}

class MyWidget extends StatelessWidget {
  final MyBloc _bloc = MyBloc();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body:  BlocPagination<TempModel, ErrorWrapper>(
        bloc: _bloc,
        blocListener: (context, state) {},
        firstPageErrorBuilder: (context, error) {
          return Center(
            child: Text(error.message.toString()),
          );
        },
        bannerPinned: true,
        banner: SliverAppBarDelegate(
          maxHeight: 100,
          minHeight: 100,
          child: Container(
            color: Colors.green,
            padding: const EdgeInsets.symmetric(vertical: 10),
            child: Text('header widget'),
          ),
        ),
        footerPinned: true,
        footer: Container(
          color: Colors.green,
          height: 100,
          width: double.infinity,
          child: Text('footer widget'),
        ),
        itemsBuilder: (context, item, index) => InkWell(
          onTap: () => _bloc.add(EditListTypePaginationEvent(
              listType: _bloc.state.listType.isListed
                  ? ListType.gridView
                  : ListType.listView)),
          child: Container(
            color: Colors.green,
            margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
            height: 200,
            child: Text('index  ${item.id}'),
          ),
        ),
      ),
    );
  }
}

Additional information #

For more information on how to use the package, please refer to the official documentation.

I hope this helps! Let me know if you have any other questions.

6
likes
130
pub points
9%
popularity

Publisher

unverified uploader

Flutter package provide easiest way to handle pagination pages using flutter_bloc state management

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

equatable, flutter, flutter_bloc, infinite_scroll_pagination

More

Packages that depend on bloc_pagination