Skip to content

a ListView and GridView support section like iOS,header pinned,item staggered

License

Notifications You must be signed in to change notification settings

lhx546920268/flutter_section_list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter_section_list

a ListView and GridView support section like iOS,header pinned,item staggered.

GridView ListView

Getting Started

Usage

dependencies:
  flutter_section_list: ^1.1.0

List

import 'package:flutter_section_list/flutter_section_list.dart';

class SectionListDemo extends StatelessWidget with SectionAdapterMixin{

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('SectionListDemo'),),
      body: SectionListView.builder(adapter: this),
    );
  }

  @override
  int numberOfSections() {
    return 10;
  }

  @override
  int numberOfItems(int section) {
    return 15;
  }

  @override
  Widget getItem(BuildContext context, IndexPath indexPath) {
    ...
  }

  @override
  bool shouldExistSectionHeader(int section) {
    return true;
  }

  @override
  bool shouldSectionHeaderStick(int section) {
    return true;
  }

  @override
  bool shouldExistSectionFooter(int section) {
    return false;
  }

  @override
  Widget getSectionHeader(BuildContext context, int section) {
    ...
  }

  @override
  Widget getSectionFooter(BuildContext context, int section) {
    ...
  }
}

Grid

import 'package:flutter_section_list/flutter_section_grid.dart';
class _SectionGridViewWidget extends StatelessWidget with SectionAdapterMixin, SectionGridAdapterMixin {

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text("SectionGridView"),
      ),
      body: SectionGridView.builder(adapter: this),
    );
  }

  @override
  Widget getItem(BuildContext context, IndexPath indexPath) {
    ...
  }

  @override
  int numberOfItems(int section) {
    return 10;
  }

  @override
  int numberOfSections() {
    return 10;
  }

  @override
  double getMainAxisSpacing(int section) {
    return 5;
  }

  @override
  double getCrossAxisSpacing(int section) {
    return 5;
  }

  @override
  EdgeInsets getSectionInsets(int section) {
    return EdgeInsets.fromLTRB(10, 8, 10, 8);
  }

  @override
  bool shouldExistSectionHeader(int section) {
    return true;
  }

  @override
  bool shouldSectionHeaderStick(int section) {
    return true;
  }

  @override
  bool shouldExistSectionFooter(int section) {
    return false;
  }

  @override
  double getFooterItemSpacing(int section) {
    return 5;
  }

  @override
  double getHeaderItemSpacing(int section) {
    return 5;
  }

  @override
  Widget getSectionHeader(BuildContext context, int section) {
    ...
  }

  @override
  Widget getSectionFooter(BuildContext context, int section) {
    ...
  }
}

About

a ListView and GridView support section like iOS,header pinned,item staggered

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages