infinite_listview_package 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

Infinite ListView #

Flutter package that provides infinite scroll listiview widget.

Getting Started #

  1. Installation Guide
  2. Example

Usage Guide #

  1. Create a class extending InfiniteListView<T>, where T is type of item on list you are going to build.
  2. Implement method getItemWidget(T item), this method should return widget for single item on list.
  3. Implement method getListData(int pageNumber), this is async method and should return list of item according to pageNumber in parameter. This method should return Future.error(...) in case of error.
  4. Override method getLoadingWidget(), getPaginationLoadingWidget(), getErrorWidget(dynamic error), getPaginationErrorWidget(dynamic error) to customize widgets while request in progress and error.

1.0.3 #

  • Dynamic per page count value

1.0.2 #

  • Implement Infinite ListView Widget

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:infinite_listview_package/infinite_listview_package.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Infinite ListView Example',
      home: InfiniteListViewExample(),
    );
  }
}

class InfiniteListViewExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Infinite ListView Example")),
      body: InfiniteListViewWidget(),
    );
  }
}

class InfiniteListViewWidget extends InfiniteListView<Photo> {
  @override
  Widget getItemWidget(Photo item) {
    return Card(
      child: Column(
        children: <Widget>[
          Image.network(
            item.thumbnailUrl,
            fit: BoxFit.fitWidth,
            width: double.infinity,
            height: 160,
          ),
          Padding(
            padding: const EdgeInsets.all(16),
            child: Text(item.title,
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
          ),
        ],
      ),
    );
  }

  @override
  Future<List<Photo>> getListData(int pageNumber) async {
    final response = await http
        .get("https://jsonplaceholder.typicode.com/photos?_page=$pageNumber");
    if (response.statusCode == 200)
      return Photo.parseList(json.decode(response.body));
    else
      return Future.error("Something went wrong.");
  }
}

class Photo {
  final String title;
  final String thumbnailUrl;

  Photo(this.title, this.thumbnailUrl);

  factory Photo.fromJson(Map<String, dynamic> json) {
    return Photo(json["title"], json["thumbnailUrl"]);
  }

  static List<Photo> parseList(List<dynamic> list) {
    return list.map((i) => Photo.fromJson(i)).toList();
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  infinite_listview_package: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:infinite_listview_package/infinite_listview_package.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [infinite_listview_package] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test