voyager_list 0.2.0 copy "voyager_list: ^0.2.0" to clipboard
voyager_list: ^0.2.0 copied to clipboard

Voyager add-on package. Facilitates dynamic mapping of a list of arbitrary objects to a ListWiew.

pub package Codemagic build status codecov

voyager_list #

Allows mapping a list of arbitrary objects to a list view.

voyager-keynote 001

Usage #

Say you have 3 different classes...

class Shoe {
    final id;
    final name;
    Shoe(this.id, this.name);
}

class Bulb {
    final id;
    final name;
    Bulb(this.id, this.name);
}

class Duck {
    final id;
    final name;
    Duck(this.id, this.name);
}

...a mixed list of items of these types:

final items = [
    Shoe("mk", "Mike"),
    Bulb("bl", "Phillip"),
    Duck("rb", "Rubber")
]

and respective widgets:

class ShoeWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final Shoe shoe = Provider.of<VoyagerArgument>(context).value;
    return Text("Shoe: ${shoe.name}");
  }
}

class DuckWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final Duck duck = Provider.of<VoyagerArgument>(context).value;
    return Text("Duck: ${duck.name}");
  }
}

class BulbWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final Bulb bulb = Provider.of<VoyagerArgument>(context).value;
    return Text("Bulb: ${bulb.name}");
  }
}

You can simply map your object list to a list view:

String idMapper(dynamic item) => item.id;
String objectMapper(dynamic item) =>
      "/object/${item.runtimeType}";
VoyagerListView(items, idMapper, objectMapper);

provided your navigation map specifies following mapping:

'/object/:className':
  type: object_item
  widget: "%{className}Widget"
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Voyager add-on package. Facilitates dynamic mapping of a list of arbitrary objects to a ListWiew.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, provider, voyager

More

Packages that depend on voyager_list