Fair 2.0 release! What’s new
hero

Flutter Fair

A Flutter package used to update widget dynamically

Get Started →

Lightweight Runtime

The core runtime contains only 2.6k lines of Dart. No worry about size.

Seamless Integration

Coding with pure Dart. Integrate package with few configuration.

Expandable Widgets

Custom/3rd Widgets mapping can be easily extended with annotation.

# Quick Start

Use Flutter Fair require few steps.

step1:download fair project source code

It is recommended to download fair (opens new window) to the local and dependencies on the relative path.

The download method is as follows:

git clone https://github.com/wuba/fair.git
1

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: 2.3.0

# add compiler dependency
dev_dependencies:
  build_runner: ^2.0.0
  fair_compiler:
    path: ../fair/compiler
 
# switch "fair_version" according to the local Flutter SDK version
dependency_overrides:
  fair_version: 2.0.6+1
1
2
3
4
5
6
7
8
9
10
11
12
13

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({})}),
  ),
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

step4:Import a dynamic widget as FairWidget

FairWidget(
  name: 'DynamicWidget',
  path: 'assets/bundle/lib_src_page_dynamic_widget.fair.json',
  data: {"fairProps": json.encode({})}),
1
2
3
4