Fair 2.0 release! What’s new

# Dynamic UI

# scenes to be used

Supports the dynamization of basic types and custom types (not inheriting Flutter components) in an interface. Different from the embedded variables and methods of delegate, logic dynamization can automatically complete the binding and invocation of variables and methods.

# Preview effect

listCell

# Integration

# 1. Define variables in State (support basic types and pure custom types; same as Flutter native development)

As in the sample example, the defined DemoList object
DemoList _demoList = DemoList(list: List.empty(), total: 0);

# 2. Variable usage in State Build (same as Flutter native syntax support)

# base type

 Text('$total'),

# custom object type

 Text('${_demoList.total}'),

# 3. Life cycle

# onLoad

The variable initialization method needs to declare a separate onLaunch to complete data initialization and network access operations.
In native development, it is generally called in initState; when used in dynamic interface, it is called after the logic file is initialized.

# onUnload

If there are resources that need to be recycled, you need to declare a separate onDispose method.
In native development, it is generally called in dispose; when used in dynamic interface, it is called after the widget is destroyed.

# 4. Binding events

It is recommended to separate the processing methods such as onTap and onPressed into methods. Such as the response method of onPressed in the example:

// define method
void onTapText() {
    setState(fairProps['pageName'], {_demoList.total: _demoList.total++});
}

// bind method
FloatingActionButton(
    child: Icon(Icons.add),
    onPressed: onTapText,
)

# 5. Logic processing (same as Flutter native development)

In the example, the user clicks the "plus" button once, and the value increases by one
_demoList.total++

# 6. Data synchronization

# To specify variable synchronization, you need to specify the synchronized variable name and result in the parameter Map, as follows:

setState({_demoList.total: _demoList.total++});

# Full, pass the parameter Map, it can be empty, as follows:

setState({});

# About variables

# Flutter internal type variable support method

You can use the delegate in the Fair framework to complete the type of pre-buried. See examples of loading more Lists.
Last Update: 6/28/2022, 4:40:25 PM
Copyright © 2020 58.com | Powered by The Fair Authors