pagination_view 0.6.0 copy "pagination_view: ^0.6.0" to clipboard
pagination_view: ^0.6.0 copied to clipboard

outdated

Flutter package to simplify pagination of list of items from the internet.

example/lib/main.dart

import 'package:example/user.dart';
import 'package:faker/faker.dart';
import 'package:flutter/material.dart';
import 'package:pagination_view/pagination_view.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('PaginationView Example')),
      body: PaginationView<User>(
        itemBuilder: (BuildContext context, User user) {
          return ListTile(
            title: Text(user.name),
            subtitle: Text(user.email),
            leading: IconButton(
              icon: Icon(Icons.person),
              onPressed: () => null,
            ),
          );
        },
        pageFetch: pageFetch,
        onError: (dynamic error) => Center(
          child: Text('Some error occured'),
        ),
        initialData: <User>[
          User(faker.person.name(), faker.internet.email()),
          User(faker.person.name(), faker.internet.email()),
        ],
        onEmpty: Center(
          child: Text('Sorry! This is empty'),
        ),
      ),
    );
  }

  Future<List<User>> pageFetch(int offset) async {
    final Faker faker = Faker();
    final List<User> nextUsersList = List.generate(
        10, (int index) => User(faker.person.name(), faker.internet.email()));
    await Future<List<User>>.delayed(Duration(seconds: 2));
    return nextUsersList;
  }
}
161
likes
0
pub points
91%
popularity

Publisher

verified publishervedartm.com

Flutter package to simplify pagination of list of items from the internet.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on pagination_view