grouping 0.0.2

Flutter Android iOS web

A component for you to group similar content, being able to add new or remove existing ones.

logo

A component for you to group similar content, being able to add new, select or remove existing ones.

Pub Package Buy Me A Coffee

Overview #

A simple data grouper

Contributing

Getting Started

In pubspec.yaml:

dependencies:
  grouping: any

Adding, Select and Removing data : #

Using grouping
import 'package:grouping/grouping.dart';

Grouping(
label: Text('Category'.toUpperCase(), style: TextStyle(color: Theme.of(context).primaryColor)),
iconAdd: Icon(
  Icons.add,
  size: 12,
  color: Theme.of(context).primaryColor,
),
labelAdd: Text('Add new category', style: TextStyle(color: Theme.of(context).primaryColor)),
height: 350,
//background: Colors.red,
items: _listItemsGroup,
onTap: (item) async {
  print('Click do Item ${item.toString()}');

  return item;
},
onRemove: <ModelExample>(item) async {
  //Simulating a call to the server
  var requestHTTP = await Future.delayed(Duration(seconds: 3));

  Future<bool> result = requestHTTP != null ? Future.value(true) : Future.value(false);

  print('Tentativa de Remover item ${item.toString()} = $result');
  return result;
},
onAdd: <ItemGroup>() async {
  ModelExample result = await Navigator.push(
    context,
    MaterialPageRoute(
      builder: (context) => TryGetValue(),
    ),
  );

  if (result == null) {
    print('No items were selected');
  } else {
    return Future.value(buildItemGroup(result));
  }
  return null;
},
),

.
.
.

buildItemGroup(ModelExample result) {
  return GroupingItem<ModelExample>(
    icon: Icon(Icons.payment, size: 35, color: Theme.of(context).primaryColor),
    remove: Icon(Icons.delete, size: 15, color: Theme.of(context).primaryColor),
    title: Text(
      '${result.name.toUpperCase()} - ${result.age}',
      style: TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold),
    ),
    titleLeading: Text('due date: ${(DateTime.now().second % 2 == 0) ? '09/27/22' : '12/27/22'}', textAlign: TextAlign.right),
    subtitle: Text(
      (DateTime.now().second % 2 == 0)
          ? '256789.48592.70.9874 0 11'
          : '000000.00000.00.0000 0 00 00000 000000 000 0 00000 0 000',
      style: TextStyle(color: Colors.grey, fontWeight: FontWeight.normal),
    ),
    subtitleLeading: Text((DateTime.now().second % 2 == 0) ? 'U\$ 777.777.77' : 'U\$ 999.999.99', textAlign: TextAlign.right),
    item: result,
    //showRemoveButton: true, // default == true
    // background: Colors.grey[500],
  );
}
Model example
class ModelExample {
  final String name;
  final int age;

  ModelExample({this.name, this.age});

  @override
  String toString() {
    return '$name $age';
  }

  factory ModelExample.fromJson(Map<String, dynamic> json) {
    if (json == null) return null;
    return ModelExample(
      name: json["name"],
      age: json["age"],
    );
  }

  static List<ModelExample> fromJsonList(List list) {
    if (list == null) return null;
    return list.map((item) => ModelExample.fromJson(item)).toList();
  }
}

Features and bugs #

Please send feature requests and bugs at the issue tracker.

0
likes
110
pub points
34%
popularity

A component for you to group similar content, being able to add new or remove existing ones.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

tiagosito@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on grouping