list_view_item_builder 1.1.0

list_view_item_builder #

Item builder for ListView,to quickly build header & item & footer,and provide jumpTo function.

Usage #

  • Create an instance of the ListViewItemBuilder.
  • Set the values of itemBuilder and itemCount of _itemBuilder to the ListView.

  ScrollController _scrollController = ScrollController();
  _itemBuilder = ListViewItemBuilder(
        // If you want use [jumpTo] or [animateTo], need set scrollController.
        scrollController:_scrollController,
        rowCountBuilder: (section) => 10,
        itemsBuilder: (BuildContext context, int section, int index) {
                    return Container(
                           height: 44,
                           child: Text('item:${section.toString()}+${index.toString()}'),
                           );
                    },
        );

  ListView.builder(
      itemBuilder: _itemBuilder.itemBuilder,
      itemCount: _itemBuilder.itemCount,
      controller: _scrollController,
    );

  // jumpTo:
  _itemBuilder.jumpTo(int section, int index, {ListViewItemPosition position = ListViewItemPosition.top})

  // animateTo:
  _itemBuilder.animateTo(int section, int index,
      {@required Duration duration,
      @required Curve curve,
      ListViewItemPosition position = ListViewItemPosition.top})

Other properties of the ListViewItemBuilder #

/// How many sections are there in total. If null. Default is 1 section.
ListViewSectionCountBuilder sectionCountBuilder;

/// How many rows are in each section.
ListViewRowCountBuilder rowCountBuilder;

/// Builder of items for each section.
ListViewItemWidgetBuilder itemsBuilder;

/// Header for each section builder, null by default.
ListViewReusableWidgetBuilder sectionHeaderBuilder;

/// Footer for each section builder, null by default.
ListViewReusableWidgetBuilder sectionFooterBuilder;

/// The item callback is OnTaped, which defaults to null.
/// If it is null, all items cannot be clicked, and there is no ripple effect
ListViewItemOnTapCallback itemOnTap;

/// Determines whether the item callback can be clicked on.
/// If itemOnTap == null, none of them are clickable.
/// If itemOnTap! = null, the return value of itemShouldTap determines whether an item can be clicked or not.
ListViewItemShouldTapCallback itemShouldTap;

/// The header widget builder for the entire listView, which defaults to null.
ListViewWidgetBuilder headerWidgetBuilder;

/// The footer widget builder for the entire listView, which defaults to null.
ListViewWidgetBuilder footerWidgetBuilder;

/// Gets the Context of the listView.
BuildContext get listViewContext => _listViewContext;

/// listViewContext
BuildContext _listViewContext;

Screenshot #

[0.0.1]

  • First release, see usage for details.

[0.0.2]

  • Added example.

[0.3.0]

  • Modified comments.

[0.4.0]

  • Fixed bug.

[0.5.0]

  • Fixed bug
  • Modified interfaces
  • 1.'headerWidget' => 'headerWidgetBuilder'
  • 2.'footerWidget' => 'footerWidgetBuilder'

[0.6.0]

  • Added loadMoreWidgetBuilder property.

[0.7.0]

  • Fixed loadMoreWidgetBuilder property.

[0.8.0]

  • Removed required property limit.

[0.9.0]

  • Modified example and screenshot.

[1.0.0]

  • Added jumpTo(section,index) and animateTo(section,index,animation) functions.

[1.1.0]

  • Fixed jumpTo and animateTo function offset bug.

example/README.md

list_view_item_builder #

A new Flutter application.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  list_view_item_builder: ^1.1.0

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:list_view_item_builder/list_view_item_builder.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
61
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]
80
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/list_view_item_builder.dart. (-0.50 points)

Analysis of lib/list_view_item_builder.dart reported 1 hint:

line 547 col 23: This function has a return type of 'bool', but doesn't end with a return statement.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test