Flutter ListGroup package


Flutter - SapidLabs

ListGroup package flutter

We are happy to announce, we have started contributing to the flutter community. Recently we released ListGroup.

ListGroup

A flutter package that enables flutter developer to use Grouped list in flutter, which looks something like:


Basics of ListGroup Package flutter

Group list can be easily generated with use of two primary Widgets that list_group package provides i.e ListGroup and ListGroupItem.


Add dependency to pubspec.yaml

This is the very first step for using package. pubspec.yaml is the place where we specify dependencies required for the application. Simply, add list_group to the flutter dependencies.

dependencies:
  flutter:
    sdk: flutter
  list_group:

Run the following command to fetch the package.

  flutter pub get


Example Implementation of ListGroup in flutter

import 'package:list_group/list_group.dart';
import 'package:list_group/list_group_item.dart';


ListGroup(
  items: [
    ListGroupItem(
      leading: Icon(
        FontAwesomeIcons.solidHeart,
        color: Colors.red,
      ),
      title: Text('Likes'),
      subtitle: Text('5 new', style: TextStyle(fontSize: 15),),
      trailing: Icon(Icons.chevron_right),
    ),
    ListGroupItem(
      leading: Icon(
        FontAwesomeIcons.eye,
        color: Colors.green,
      ),
      title: Text('Visitors'),
      subtitle: Text('10 recent', style: TextStyle(fontSize: 15),),
      trailing: Icon(Icons.chevron_right),
    ),
    ListGroupItem(
      leading: Icon(
        FontAwesomeIcons.userFriends,
        color: Colors.blue,
      ),
      title: Text('Followers'),
      subtitle: Text('Trusted', style: TextStyle(fontSize: 15),),
      trailing: Icon(Icons.chevron_right),
      lastItem: true,
    )
  ],
);


ListGroup

The list group widget expects items to be List of ListGroupItem. This is similar to DropDownButton and DropDownMenuItem structure.


ListGroupItem

This makes up the list items within this list group.

Options

  1. leading : expects a widget to be placed within the list item.
  2. title : expects a widget, usually a Text widget which displays the text in the list.
  3. subtitle : expects a widget, usually a Text widget which is displayed below the title.
  4. trailing : expects a widget to be placed within the list item.
  5. dense : expects either true or false defaults to true, compacts height of list tile.
  6. enabled : whether list item is enabled, defaults to true.
  7. lastItem : Important this decides whether to add divider after the list item. defaults to false.
  8. onTap : expects a callback method to be executed on tap of list item.
  9. onLongPress : expects a callback method to be executed on long press of list item.


Show Some Love <3

Do give it a star to support the project. We are working on announcing some new packages and widgets. Stay Tuned for More on Flutter !!

Recommended Posts

Default Enum in Rails 6
Rails 6 provides a way to define default enum value. Let’s see how it works...
Ruby 2.7 adds Enumerable#tally
After introducing the Enumerable#tally method in Ruby 2.7-preview updates. #tally as the name suggests gives...
How to rename column name in Rails
Rails rename_column Rails provides a simple method rename_column which can be used in a migration....