WubaNovember 19, 2022Less than 1 minute

FairWidget is the container we use to load bundle resources.

  path: 'assets/bundle/lib_main.fair.json',
  data: {
    'fairProps': jsonEncode({'title': 'Hello'})

When using FairWidget, there are two main parameters.

Parameter 1: path

path represents the path to the bundled resource.

  • path can accept an assets path, such as 'assets/bundle/lib_main.fair.json'. Generally used for local debugging.

  • path can also accept an absolute path local to the phone. For example, if you host the bundle resources on your own company's server, and download them to the mobile phone during operation, use the local path of the mobile phone as the path.

Parameter 2: data

data is a parameter passed to the dynamic page, and data is a parameter of a Map<String, dynamic> structure.

Note that for the data passed to the dynamic page, the key must be fairProps, which cannot be customized, and the value is a Map type of data, which requires the jsonEncode() operation, such as:

data: {
  /// The key here must be fairProps and cannot be customized
  /// value is a Map type of data, preferably jsonEncode() operation
  'fairProps': jsonEncode({'title': 'Hello'})
Last update:
Contributors: sunzhe03