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"

Libraries

voyager_list

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.