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
location:/example/lib/best_flutter_ui
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.0.0
# add build_runner and compiler dependency
dev_dependencies:
build_runner: ^2.0.0
fair_compiler: ^1.4.1
# switch "fair_version" according to the local Flutter SDK version
# 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) -> 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_3_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({})}),
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
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
For more details, please refer to fair_tools
For more details, please refer to https://fair.58.com
Fair Cli: Fair_CLI
IEDA plugin: jetbrains_plugin_fair_template
Hot update platform: FAIR PUSHY
updateDate:2022.11.17
- Fix class constructor parsing exception.
- Fair Compatible Web.
- Bindmap logic optimization.
updateDate:2022.11.01
- Fixed:CustomScrollView reference external function builder bug.
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.
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 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.
updateDate:2022.07.05
- 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.
updateDate:2022.05.31
Adapt to flutter SDK 2.8.0, 2.8.1
Dart2js supports parsing singletons
New syntax Sugar.switchCase、Sugar.colorsWithOpacity、Sugar.convertToString, etc
Comprehensively optimize the example structure and upgrade the example experience, which is more suitable for beginners.
In the source code, an example project is added to provide the standard usage of fair API.
example location:fair/example
updateDate:2022.05.12
Fix FairLogger import problem.
Upgrade Analyzer to 2.3.0.
updateDate:2022.04.26
FlatBuffers supports generating bin files in a null safe environment
updateDate: 2022.04.22
supports null-safe
Adapt to Flutter SDK 2.5.0, 2.5.1, 2.5.2, 2.5.3 and other versions
Upgrade the outdated demo in the sample project
Supplement the iOS runtime environment in the sample project
- Major release plan
- null-safe version support, expected to be launched on April 22 ✅
- Flutter 2.8.0 version adaptation, expected to be launched in mid-May ✅
- Flutter 2.10.0 version adaptation, is expected to be launched in early June ✅
- Flutter 3.0 version adaptation ✅
- IDE syntax detection and hint plugin ✅
- Rich syntactic sugar
- Hot update platform
- Dart Server project construction ✅
- Flutter Web project construction ✅
- Patch/resource management ✅
- Project management ✅
- Mobile Update&Download ✅
- Online dynamic
- Flutter Web project construction ✅
- Dart Server project construction ✅
- ActionEdit
- Code editing ✅
- Component editing
- Page editing
- Engineering editor
- Flutter effect preview
- Fair DSL preview
- IDE plug-in
- Fair project generation
- Fair template generation
- Fair syntax detection
58阿姨 |
移动经纪人 |
安居拍房 |
神奇保 |
58商办通 |
58商家版 |
中华英才网 |
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Copyright (C) 2005-present, 58.com. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of 58.com nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.