Fair 2.0 release! What’s new

# ListView.builder with dynamic cells

# scenes to be used

In the native list, it is used when we need to dynamically display a card or a piece of content.
For example: in the face of the situation that the simple control display of the API cannot be satisfied, when making the overall UI adjustment for a piece of content, you can hide the original content and replace it with a dynamic Cell to achieve the goal.

# Preview effect

listCell

# Integration

The overall design adopts a combination method, and developers only need to pre-embed dynamic type cells in the list that needs to support dynamic cells. The following item.type == 'fair' (if the list content is delivered to the backend, the dynamic type needs to be communicated with the backend in advance) to identify a dynamic type.

Widget getItem(var item) {
    if (item.type == 'fair') { // Dynamic Cell
      // Dynamic Cell
      return Container( // placeholder container
          alignment: Alignment.centerLeft,
          color: Colors.white,
          constraints: BoxConstraints(minHeight: 80),
          child: FairWidget(
            name: id, // Cell unique id
            path: 'assets/bundle/lib_src_page_list_cells_sample_page_stateful_cell.fair.bin', // http online or local differential package
            data: {"fairProps": json.encode(louPanDetail)}, // dynamic content passed to Cell
          ));
    }
}
Last Update: 6/28/2022, 4:40:25 PM
Copyright © 2020 58.com | Powered by The Fair Authors