flutter_section_list_view 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

flutter_section_list_view #

A flutter list view which supports sections like iOS UITableView with no overhead

Usage #

To use this plugin, add flutter_section_list_view as a dependency in your pubspec.yaml file.

Getting Started #

Import this class #

import 'flutter_section_list_view/flutter_section_list_view.dart';

Add flutter_section_list_view Widget #

After importing this plugin to your project, you can simply use it as a normal widget


FlutterSectionListView(
        numberOfSection: 4,
        numberOfRowsInSection: (section) {
          return section * 3 + 1;
        },
        sectionWidget: (section) {
          return Container(child: Padding(
            padding: const EdgeInsets.all(8),
            child: Text('Section $section'),
          ), color: Colors.grey,);
        },
        rowWidget: (section, row) {
          return Container(
            child: Padding(
              padding: EdgeInsets.all(8),
              child: Text('Row $section - $row'),
            ),
          );
        },
      )

To use Pull-To-Refresh feature, simply provide value to attribute 'refresh', a callback function

listView.refresh = () async {
      await new Future.delayed(new Duration(seconds: 3));
      print('List Refreshed');
    };

For Pagination feature, provide value to attribute 'loadMoreData', a callback function

listView.loadMoreData = () async {
      await new Future.delayed(new Duration(seconds: 2));
      print('More Data loaded and List refreshed');
      /// set 'isMoreAvailable' attribute to 'false' when there are no more pages to return 
      listView.isMoreAvailable = false;
    };

[0.0.1] - 3-December-2019. #

  • Initial Release

[0.1.0] - 4-December-2019. #

  • Added License

[1.0.0] - 5-January-2020. #

  • flutter_section_list extended to support 'Pagination' and 'Pull-To_Refresh'

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_section_list_view/flutter_section_list_view.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Section List View'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<List<String>> items = [
    ['Item 1', 'Item 2', 'Item 3'],
    ['Item 4', 'Item 5'],
    ['Item 6', 'Item 7', 'Item 8', 'Item 9'],
    ['Item 10', 'Item 11'],
    ['Item 12', 'Item 13'],
    ['Item 14', 'Item 15', 'Item 16'],
    ['Item 17', 'Item 18']
  ];

  @override
  Widget build(BuildContext context) {
    FlutterSectionListView listView = FlutterSectionListView(
      numberOfSection: () => items.length,
      numberOfRowsInSection: (section) {
        return items[section].length;
      },
      sectionWidget: (section) {
        return Container(
          child: Padding(
            padding: const EdgeInsets.all(8),
            child: Text('Section $section'),
          ),
          color: Colors.grey,
        );
      },
      rowWidget: (section, row) {
        return Container(
          child: Padding(
            padding: EdgeInsets.all(8),
            child: Text(items[section][row]),
          ),
        );
      },
    );

    listView.loadMoreData = () async {
      await new Future.delayed(new Duration(seconds: 2));
      items.add(['Item 19', 'Item 20']);
      items.add(['Item 21', 'Item 22', 'Item 23']);
      items.removeAt(0);
      items.insert(0, ['Item 0-1', 'Item 1-2']);
      listView.isMoreAvailable = false;
    };

    listView.refresh = () async {
      await new Future.delayed(new Duration(seconds: 3));
      items.removeAt(0);
    };

    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: listView);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_section_list_view: ^1.0.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:flutter_section_list_view/flutter_section_list_view.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
56
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]
78
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

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.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test