Fair
A Flutter package used to update widget tree dynamically. Fair提供一整套Flutter动态化解决方案
Install / Use
/learn @wuba/FairREADME

Fair is a dynamic framework designed for Flutter. Through the automatic conversion of native Dart source files by the Fair Compiler tool, the project can obtain the ability to dynamically update the Widget Tree and State.
The goal of creating Fair is to support updates through business bundles and JS distribution without the release of versions (Android, iOS, Web), similar to React Native. After integrating with Flutter Fair, you can quickly publish new pages without waiting for your app's next release date. Fair provides standard widgets, which can be used as a new dynamic page or as part of an existing Flutter page, such as typography/style modification of operation bits, full page replacement, partial replacement, etc.

Fair's UI rendering is lossless and can be restored at the pixel level. Take a look at the effect of escaping some pages of Best Flutter UI Templates:

The project used is from https://github.com/mitesh77/Best-Flutter-UI-Templates </br> location:/example/lib/best_flutter_ui
🏛Architecture

🚀 Running
Use Flutter Fair require few steps.
step1:download fair project source code
It is recommended to download fair to the local and dependencies on the relative path.
The download method is as follows:
git clone https://github.com/wuba/fair.git
step2:Add dependency inside pubspec.yaml
Assuming that the fair project and your own project are in the same folder:
# add Fair dependency
dependencies:
fair: 3.2.1
# add build_runner and compiler dependency
dev_dependencies:
build_runner: ^2.0.0
fair_compiler: ^1.7.0
# switch "fair_version" according to the local Flutter SDK version
# Flutter SDK 3.7.x(3.7.0、3.7.1、3.7.2、3.7.3、3.7.4、3.7.5、3.7.6、3.7.7、3.7.8、3.7.9、3.7.10) -> flutter_3_7_0
# Flutter SDK 3.3.x(3.3.0、3.3.1、3.3.2、3.3.3、3.3.4、3.3.5、3.3.6、3.3.7、3.3.8、3.3.9、3.3.10) -> flutter_3_3_0
# Flutter SDK 3.0.x(3.0.0、3.0.1、3.0.2、3.0.3、3.0.4、3.0.5) -> flutter_3_0_0
# Flutter SDK 2.10.x(2.10.0、2.10.1、2.10.2、2.10.3) -> flutter_2_10_0
# Flutter SDK 2.8.x(2.8.0、2.8.1) -> flutter_2_8_0
# Flutter SDK 2.5.x(2.5.0、2.5.1、2.5.2、2.5.3) -> flutter_2_5_0
# Flutter SDK 2.0.6 -> flutter_2_0_6
# Flutter SDK 1.22.6 -> flutter_1_22_6
dependency_overrides:
fair_version:
path: ../fair/flutter_version/flutter_3_7_0
step3:Wrap your app with FairApp Widget
void main() {
WidgetsFlutterBinding.ensureInitialized();
FairApp.runApplication(
_getApp(),
plugins: {
},
);
}
dynamic _getApp() => FairApp(
modules: {
},
delegate: {
},
child: MaterialApp(
home: FairWidget(
name: 'DynamicWidget',
path: 'assets/bundle/lib_src_page_dynamic_widget.fair.json',
data: {"fairProps": json.encode({})}),
),
);
step4:Import a dynamic widget as FairWidget
FairWidget(
name: 'DynamicWidget',
path: 'assets/bundle/lib_src_page_dynamic_widget.fair.json',
data: {"fairProps": json.encode({})}),
DevTools
fair development tools
Dart Commandline Tool faircli
create fair project
faircli install
dart pub global activate faircli
create fair dynamic project
faircli create -n dynamic_project_name
create fair carrier project
faircli create -k carrier -n carrier_project_name
IDEA Plugin FairTemplate
Page/Component Template Code
<html> <img src="resources/fair_template.png" width="80%"> </html>DevTools flow chart

DevTools demo
After using faircli to configure the local hot update service, open the developer options on the mobile device, select the local mode, enter the ip of the development machine, then preview fair dynamic effect
<html> <div align="center"> <img src="resources/fair_tools.gif" width="30%"> </div> </html>For more details, please refer to fair_tools
Fair-Online Platform
Fair-Online is an integrated cloud development platform for Flutter developers, from online development of Flutter, to real-time compilation and preview, packaging and publishing, and dynamic release of end-side updates, to realize the dynamic online Flutter.
Developers do not need to configure the Flutter development environment, develop and debug code online, compile and preview in real time, and what you see is what you get. Combined with the Flutter dynamic framework Fair and the hot update platform FairPushy created by the 58 open source team, Flutter online dynamics are realized.
<html> <div align="center"> <img src="./fair_online/fair_online.gif" width="90%"> </div> </html>Online experience URL: Fair-Online Platform
For more details, please refer to fair_online
Documentation
For more details, please refer to https://fair.58.com
Tools
Fair Cli: Fair_CLI
IEDA plugin: jetbrains_plugin_fair_template
Hot update platform: FAIR PUSHY
versions
3.10.0
updateDate: 2023.08.15
- Adapted to Flutter 3.10.0, released Fair Version 3.10
- Fix known bugs, fix DSL parser issues
3.2.1
updateDate:2023.04.13
- Fixed some issues.
3.2.0
updateDate:2023.04.12
- Adjust the order of dispose calls, not above the tree, subsequent operations stop
- Add generic FairPlugin js and dart code, reuse the same interaction logic, add example comments
- Json parsing compatibility
- Add exception catching and log printing when executeFunction is called with V8 engine in Android
- Fix SliverGridDelegateWithFixedCrossAxisCount conversion error.
- SugarMap and SugarMapEach inputs support other Sugar expressions
- Optimize the performance of ifEqual ifEqualBool switchCase
- Fix Domain not recognizing index and item in sugar
- Make AOT also follow conditions before executing code
- Fix SugarMap and SugarMapEach set input does not support other Sugar syntax
- Abstract Domain, add IndexDomain, MapEachDomain, support nested Domains
- New FunctionDomain generic Domain, generate corresponding parameters for function callbacks for FunctionDomain to use.
- Added NullableIndexedWidgetBuilder, IndexedWidgetBuilder, WidgetBuilder, TransitionBuilder common Sugar support
- Some known issues fixed
3.1.0
updateDate:2023.03.14
- Upgrade analyzer library to 5.5.0;
- Dart function to JS supports parameter passing;
- JS Object value compatibility;
- Remove kotlin dependencies from fair/android;
- Add custom parsing for IconData;
- The generation of optional positional parameters is modified to obtain pa;
- Fixed missing OptionalPositional default values;
- Remove the generation time from the generation.fair. dart comment;
- Added the ignore unnecessary_import operation;
- Fixed incorrect assignment of Sugar.switchCase key and defaultValue;
- binding was changed to SplayTreeMap to increase search efficiency, especially for lists, where duplicate tags are searched for a short time;
- Exposing specialBinding so that users can override a value;
- When the provider is added to the _binding, the Settings set by the user prevail for quick modification;
- Fixed the loadCoreJs package splicing problem;
- Reduced minSdkVersion to 16;
- runApplication supports specifying the package in which the JS resides;
- Fixed error in calling context in the _reload method.
3.0.0
updateDate:2022.11.17
- Fix class constructor parsing exception.
- Fair Compatible Web.
- Bindmap logic optimization.
2.8.1
updateDate:2022.11.01
- Fixed:CustomScrollView reference external function builder bug.
2.8.0
updateDate:2022.10.21
- Add support of Flutter SDK 3.3.0+.
- Add Sugar:Sugar.isNestedScrollViewHeaderSliversBuilder、Sugar.isButtonStyle、Sugar.isDuration、Sugar.popMenuButton、Sugar.sliverChildBuilderDelegate、Sugar.sliverGridDelegateWithFixedCrossAxisCount.
- Fixed some bugs.
2.7.0
updateDate:2022.08.10
- Add support of Flutter SDK 3.0.0、3.0.1、3.0.2、3.0.3、3.0.4、3.0.5.
- Fixed some bugs.
Fair
- Fair supports loading bundle files on the phone disk path;
- Adapt to Flutter SDK 2.10.0, 2.10.1, 2.10.2, 2.10.3;
- Dart2JS supports parsing static methods;
- When running, the page error message prompts optimization;
- Syntactic sugar supports parsing Model data.
2.6.0
updateDate:2022.07.05
Fair
- Fair supports loading bundle files on the phone disk path;
- Adapt to Flutter SDK 2.10.0, 2.10.1, 2.10.2, 2.10.3;
- Dart2JS supports parsing static methods;
- When running, the page error message prompts optimization;
- Syntactic sugar supports parsing Model data.
2.5.0
updateDate:2022.05.31
Fair
Adapt to flutter SDK 2.8.0, 2.8.1
Dart2js supports pa
