A Flutter package used to update widget tree dynamically

Last update: Aug 12, 2022

social preview

pub github doc license build Gitter

简体中文|English


Fair is a lightweight package for Flutter, which can be used to update widget tree and state dynamically. This package is still at an early stage.

We create Fair so we can dispatch any pages changes to users as bundle(s), the way similar to React Native. With Flutter Fair integrated, you can publish your pages without waiting for the next release date of your App. Fair provides standard widget and some logic plugins, it can be used as a new dynamic page or as part of existing Flutter page.

Quick Start

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:
    path: ../fair/fair

# add compiler dependency
dev_dependencies:
  build_runner: ^1.4.0
  fair_compiler:
    path: ../fair/compiler
 
# switch "fair_version" according to the local Flutter SDK version
dependency_overrides:
  fair_version:
    path: ../fair/flutter_version/flutter_2_0_6

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({})}),

Documentation

For more details, please refer to https://fair.58.com

Support

The simplest way to show us your support is by giving the project a star.

GitHub

https://github.com/wuba/fair
Comments
  • 1. run build_runner build error

    问题

    执行 flutter pub run build_runner build 转换时,报错。

    Bad state: Unexpected diagnostics:
    /Users/yyinc/fvm/versions/2.5.0/bin/cache/dart-sdk/lib/core/int.dart:117:18 - Operator declarations must be preceded by the keyword 'operator'.
    /Users/yyinc/fvm/versions/2.5.0/bin/cache/dart-sdk/lib/core/int.dart:117:16 - Methods must have an explicit list of parameters.
    /Users/yyinc/fvm/versions/2.5.0/bin/cache/dart-sdk/lib/core/int.dart:117:18 - A function body must be provided.
    

    环境信息

    [✓] Flutter (Channel unknown, 2.5.0, on macOS 11.5.2 20G95 darwin-x64, locale zh-Hans-CN)
        • Flutter version 2.5.0 at /Users/yyinc/fvm/versions/2.5.0
        • Upstream repository unknown
        • Framework revision 4cc385b4b8 (3 months ago), 2021-09-07 23:01:49 -0700
        • Engine revision f0826da7ef
        • Dart version 2.14.0
        • Flutter download mirror https://storage.flutter-io.cn
    
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/yyinc/Library/Android/sdk
        ✗ cmdline-tools component is missing
          Run `path/to/sdkmanager --install "cmdline-tools;latest"`
          See https://developer.android.com/studio/command-line for more details.
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 13.0, Build version 13A233
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2020.3.3)
        • IntelliJ at /Applications/IntelliJ IDEA.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin version 203.7759
    
    [✓] VS Code (version 1.62.3)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.28.0
    
    [✓] Connected device (3 available)
        • V1824BA (mobile) • 9ce2cf42                  • android-arm64  • Android 11 (API 30)
        • iPhone (mobile)  • 00008030-001269112EE3402E • ios            • iOS 14.8.1 18H107
        • Chrome (web)     • chrome                    • web-javascript • Google Chrome 96.0.4664.55
    
    ! Doctor found issues in 1 category.
    

    复现步骤

    在 master 分支下的 fair example 运行命令。

    commit: e76062a61da0de870862b2897b032e1fb6fafd87

    Reviewed by silan-liu at 2021-11-26 01:09
  • 2. Fair2.0执行flutter pub run build_runner build问题

    问题

    执行flutter pub run build_runner build无法获得产物

    环境信息

    likairandeMacBook-Pro:fair_list_demo zyb$ flutter --version
    Flutter 2.0.6 • channel unknown • unknown source
    Framework • revision 1d9032c7e1 (4 months ago) • 2021-04-29 17:37:58 -0700
    Engine • revision 05e680e202
    Tools • Dart 2.12.3
    
    likairandeMacBook-Pro:fair_list_demo zyb$ flutter doctor --verbose
    [✓] Flutter (Channel unknown, 2.0.6, on macOS 11.0.1 20B50 darwin-x64, locale zh-Hans-CN)
        • Flutter version 2.0.6 at /Users/zyb/flutter
        • Framework revision 1d9032c7e1 (4 months ago), 2021-04-29 17:37:58 -0700
        • Engine revision 05e680e202
        • Dart version 2.12.3
        • Pub download mirror https://pub.flutter-io.cn
        • Flutter download mirror https://storage.flutter-io.cn
    

    Fair版本号

    dependencies:
      fair: x.y.z
    fair main分支,
    commit 241fa80c0ca84a9da1376a6004f02b99f0ad6c50
    
    image

    操作过程

    以samples/fair_list_demo为例 image

    likairandeMacBook-Pro:fair_list_demo zyb$ flutter pub run build_runner build
    [INFO] Generating build script...
    [INFO] Generating build script completed, took 385ms
    
    [INFO] Creating build script snapshot......
    [INFO] Creating build script snapshot... completed, took 11.0s
    
    [INFO] Initializing inputs
    [INFO] Building new asset graph...
    [INFO] Building new asset graph completed, took 625ms
    
    [INFO] Checking for unexpected pre-existing outputs....
    [INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
    
    [INFO] Running build...
    [WARNING] fair_compiler:fairc on lib/main.dart:
    Your current `analyzer` version may not fully support your current SDK version.
    
    Please try upgrading to the latest `analyzer` by running `flutter packages upgrade`.
    
    Analyzer language version: 2.10.0
    SDK language version: 2.12.0
    
    If you are getting this message and have the latest analyzer please file
    an issue at https://github.com/dart-lang/sdk/issues/new with the title
    "No published analyzer available for language version 2.12.0".
    Please search the issue tracker first and thumbs up and/or subscribe to
    existing issues if present to avoid duplicates.
    
    [INFO] Generating SDK summary...
    [SEVERE] fair_compiler:fairc on lib/main.dart:
    
    Bad state: Unexpected diagnostics:
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:166:25 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:539:15 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:390:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:30:49 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:18:62 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:42:22 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:327:34 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:376:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:516:13 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:224:29 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:65:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:58:17 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:41:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:132:29 - This requires the 'non-nullable' language feature to be enabled.
    [SEVERE] fair_compiler:fairc on lib/main.dart:
    
    Bad state: Unexpected diagnostics:
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:166:25 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:539:15 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:390:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:30:49 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:18:62 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:42:22 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:327:34 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:376:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:516:13 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:224:29 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:65:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:58:17 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:41:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:132:29 - This requires the 'non-nullable' language feature to be enabled.
    [SEVERE] fair_compiler:fairc on lib/main.dart:
    
    Bad state: Unexpected diagnostics:
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:166:25 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:539:15 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:390:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:30:49 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:18:62 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:42:22 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:327:34 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:376:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:516:13 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:224:29 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:65:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:58:17 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:41:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:132:29 - This requires the 'non-nullable' language feature to be enabled.
    [SEVERE] fair_compiler:fairc on lib/main.dart:
    
    Bad state: Unexpected diagnostics:
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:166:25 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:539:15 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:390:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:30:49 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:18:62 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:42:22 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:327:34 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:376:19 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:516:13 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:224:29 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:65:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:58:17 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:41:23 - This requires the 'non-nullable' language feature to be enabled.
    /Users/zyb/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:132:29 - This requires the 'non-nullable' language feature to be enabled.
    [INFO] 2.6s elapsed, 1/4 actions completed.
    [INFO] 3.7s elapsed, 1/4 actions completed.
    [INFO] 4.7s elapsed, 1/4 actions completed.
    [INFO] 5.7s elapsed, 1/4 actions completed.
    [INFO] 6.8s elapsed, 1/4 actions completed.
    [INFO] 7.9s elapsed, 1/4 actions completed.
    [INFO] 8.9s elapsed, 1/4 actions completed.
    [INFO] 10.0s elapsed, 1/4 actions completed.
    [INFO] 11.1s elapsed, 1/4 actions completed.
    [INFO] 12.2s elapsed, 1/4 actions completed.
    [INFO] 13.3s elapsed, 1/4 actions completed.
    [INFO] 14.4s elapsed, 1/4 actions completed.
    [INFO] 15.5s elapsed, 1/4 actions completed.
    [WARNING] No actions completed for 15.0s, waiting on:
      - fair_compiler:fairc on lib/JRList.dart
      - fair_compiler:fairc on lib/my_list.dart
      - fair_compiler:fairc on lib/list_proxy.dart
    

    之后会一直循环输出

    [INFO] 17.6s elapsed, 1/4 actions completed.
    [INFO] 18.7s elapsed, 1/4 actions completed.
    [INFO] 19.8s elapsed, 1/4 actions completed.
    [INFO] 20.9s elapsed, 1/4 actions completed.
    [INFO] 22.0s elapsed, 1/4 actions completed.
    [INFO] 23.1s elapsed, 1/4 actions completed.
    [INFO] 24.1s elapsed, 1/4 actions completed.
    [INFO] 25.2s elapsed, 1/4 actions completed.
    [INFO] 26.3s elapsed, 1/4 actions completed.
    [INFO] 27.4s elapsed, 1/4 actions completed.
    [INFO] 28.5s elapsed, 1/4 actions completed.
    [INFO] 29.6s elapsed, 1/4 actions completed.
    [INFO] 30.7s elapsed, 1/4 actions completed.
    [WARNING] No actions completed for 15.1s, waiting on:
      - fair_compiler:fairc on lib/JRList.dart
      - fair_compiler:fairc on lib/my_list.dart
      - fair_compiler:fairc on lib/list_proxy.dart
    

    请问是设置的问题吗,.dart_tool文件夹删除过并没有解决问题 如何才能输出json文件

    Reviewed by Karl87 at 2021-08-25 07:26
  • 3. 打开demo中的page_two出现异常错误:exceptionValue:TypeError: undefined is not an object

    问题

    打开demo中的page_two出现异常错误:exceptionValue:TypeError: undefined is not an object

    页面源码:

    Navigator.pushNamed(context, 'fair_page_two', arguments: { 'path': 'assets/fair/lib_developer_page2page_page_two.fair.json', 'data': {'title': 'PageTwo'} });

    import 'package:fair/fair.dart'; import 'package:flutter/material.dart';

    @FairPatch() class PageTwo extends StatefulWidget { PageTwo({Key? key, this.fairProps}) : super(key: key);

    dynamic fairProps;

    @override _PageTwoState createState() => _PageTwoState(); }

    class _PageTwoState extends State { @FairProps() var fairProps;

    @override void initState() { super.initState(); fairProps = widget.fairProps; }

    String getTitle() { return fairProps['title']; }

    @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( /// 如果需要进行字符串拼接的话,在build()方法里进行拼接即可,不建议在getTitle() /// 方法里做字符串拼接 title: Text('参数:${getTitle()}'), ), body: Container( child: Padding( padding: EdgeInsets.all(20), child: Text('xxxxx'), )), ); } }

    错误日志: [Fair]: File:FairDartBridge.m, Function:-[FairDartBridge obtainModelWithMessage:], Line:103 >> {"path":"GLOBAL['null#1']=(function(initProps){const global=this;return runCallback(function(mod){with(mod.imports){function _PageTwoState(){const inner=_PageTwoState.inner;if(this==global){return new _PageTwoState({args:arguments});}else{const args=arguments.length>0?arguments[0].args||arguments:[];inner.apply(this,args);_PageTwoState.prototype.ctor.apply(this,args);return this;}}_PageTwoState.inner=function inner(){this.fairProps=initProps;};_PageTwoState.prototype={initState:function initState(){const thiz=this;with(thiz){fairProps=widget.fairProps;}},getTitle:function getTitle(){const thiz=this;with(thiz){return fairProps.op_idx('title');}},};_PageTwoState.prototype.ctor=function(){Object.prototype.ctor.call(this);};;return _PageTwoState();}},[]);})(convertObjectLiteralToSetOrMap(JSON.parse('{"title":"PageTwo"}')));","pageName":"null#1"} [Fair]: File:FairProcessManager.m, Function:-[FairProcessManager injectionJSScriptWtihJSScript:callback:], Line:59 >> GLOBAL['null#1']=(function(initProps){const global=this;return runCallback(function(mod){with(mod.imports){function _PageTwoState(){const inner=_PageTwoState.inner;if(this==global){return new _PageTwoState({args:arguments});}else{const args=arguments.length>0?arguments[0].args||arguments:[];inner.apply(this,args);_PageTwoState.prototype.ctor.apply(this,args);return this;}}_PageTwoState.inner=function inner(){this.fairProps=initProps;};_PageTwoState.prototype={initState:function initState(){const thiz=this;with(thiz){fairProps=widget.fairProps;}},getTitle:function getTitle(){const thiz=this;with(thiz){return fairProps.op_idx('title');}},};_PageTwoState.prototype.ctor=function(){Object.prototype.ctor.call(this);};;return _PageTwoState();}},[]);})(convertObjectLiteralToSetOrMap(JSON.parse('{"title":"PageTwo"}'))); [Fair]: File:FairJSBridge.m, Function:-[FairJSBridge context]_block_invoke, Line:220 >> exceptionValue:ReferenceError: Can't find variable: GLOBAL [Fair]:

    环境信息

    [✓] Flutter (Channel stable, 2.10.5, on macOS 12.3 21E230 darwin-arm, locale zh-Hans-CN) • Flutter version 2.10.5 at /Users/xxx/fvm/versions/2.10.5 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5464c5bac7 (4 months ago), 2022-04-18 09:55:37 -0700 • Engine revision 57d3bac3dd • Dart version 2.16.2 • DevTools version 2.9.2 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn

    提供Fair版本号
    

    dependencies: fair: ^2.6.1

    相关截图 WX20220810-112618

    Reviewed by softAlexs at 2022-08-10 03:30
  • 4. can not compiler the demo DynamicWidget!!!!

    C:\Users\asus>flutter --version Flutter 1.22.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision 7891006299 (3 months ago) • 2020-12-10 11:54:40 -0800 Engine • revision ae90085a84 Tools • Dart 2.10.4

    error as flow:

    [SEVERE] fair_compiler:fairc on lib/gunview/dynamicwidget.dart:

    line 1, column 42 of package:flutterapp/gunview/dynamicwidget.dart: Could not resolve annotation for class DynamicWidget exten ds StatelessWidget ╷ 1 │ @FairBinding() │ ^^^^^^^^^^^^^^ ╵ [INFO] 14.9s elapsed, 2/3 actions completed.

    Reviewed by yejianhui168 at 2021-02-23 10:55
  • 5. 项目中引入 Fair 后,构建出 Release 包,安装后启动 APP 直接闪退

    问题

    在本地一个 demo 工程中引入了 Fair,然后使用 flutter build apk 构建出 Release 包,安装 APK,启动 APP 直接闪退。

    环境信息

    执行下面的语句,并粘贴结果

    [✓] Flutter (Channel stable, 3.0.5, on macOS 12.2.1 21D62 darwin-arm, locale
        zh-Hans-CN)
        • Flutter version 3.0.5 at /Users/chenyouyu/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700
        • Engine revision e85ea0e79c
        • Dart version 2.17.6
        • DevTools version 2.12.2
    
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/chenyouyu/Library/Android/sdk
        ✗ cmdline-tools component is missing
          Run `path/to/sdkmanager --install "cmdline-tools;latest"`
          See https://developer.android.com/studio/command-line for more details.
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for
          more details.
    
    [✗] Xcode - develop for iOS and macOS
        ✗ Xcode installation is incomplete; a full installation is necessary for iOS
          development.
          Download at: https://developer.apple.com/xcode/download/
          Or install Xcode via the App Store.
          Once installed, run:
            sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
            sudo xcodebuild -runFirstLaunch
        ✗ CocoaPods not installed.
            CocoaPods is used to retrieve the iOS and macOS platform side's plugin
            code that responds to your plugin usage on the Dart side.
            Without CocoaPods, plugins will not work on iOS or macOS.
            For more info, see https://flutter.dev/platform-plugins
          To install see
          https://guides.cocoapods.org/using/getting-started.html#installation for
          instructions.
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build
          11.0.12+0-b1504.28-7817840)
    
    [✓] VS Code (version 1.69.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension can be installed from:
          🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    
    [✓] Connected device (3 available)
        • JEF AN00 (mobile) • E6EDU20429059373 • android-arm64  • Android 10 (API
          29)
        • macOS (desktop)   • macos            • darwin-arm64   • macOS 12.2.1 21D62
          darwin-arm
        • Chrome (web)      • chrome           • web-javascript • Google Chrome
          104.0.5112.79
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 2 categories.
    

    提供Fair版本号

    dependencies:
      fair: 2.7.0
    

    复现操作【可选】

    1.使用 flutter build apk 构建出 Release 包; 2.安装并启动 APP,直接闪退。

    Reviewed by yancechen at 2022-08-12 06:26
  • 6. flutter pub run build_runner build 报错

    flutter版本 2.5.0 使用 flutter pub run build_runner build 转换报错

    Failed to build build_runner:build_runner: ../../../../../../.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:258:50: Error: The property 'displayString' is defined in multiple extensions for 'TargetKind' and neither is more specific.

    • 'TargetKind' is from 'package:meta/meta_meta.dart' ('../../../../../../.pub-cache/hosted/pub.flutter-io.cn/meta-1.7.0/lib/meta_meta.dart'). Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope. var kindNames = kinds.map((kind) => kind.displayString).toList() ^^^^^^^^^^^^^ ../../../../../../.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:1950:14: Context: This is one of the extension members. String get displayString { ^^^^^^^^^^^^^ ../../../../../../.pub-cache/hosted/pub.flutter-io.cn/meta-1.7.0/lib/meta_meta.dart:91:14: Context: This is one of the extension members. String get displayString { ^^^^^^^^^^^^^ ../../../../../../.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:260:36: Error: The getter 'commaSeparatedWithOr' isn't defined for the class 'List'.
    • 'List' is from 'dart:core'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'commaSeparatedWithOr'. var validKinds = kindNames.commaSeparatedWithOr; ^^^^^^^^^^^^^^^^^^^^ pub finished with exit code 1
    Reviewed by LeeRHuang at 2022-02-21 08:26
  • 7. 执行flutter pub run build_runner build 命令 没有生成目录及任何文件

    环境信息

    执行下面的语句,并粘贴结果

    flutter doctor --verbose
    

    flutter版本

    2.10.5
    

    yaml文件配置

    dependencies:
      fair: fair-2.6.1
    dev_dependencies:
     fair-2.6.1/compiler
     build_runner: 2.2.0
    dependency_overrides:
     fair_version:fair-2.6.1/flutter_version/flutter_2_10_0
    

    相关截图【可选】

    image image image image

    其他【可选】 代码为文档提供的计数器案例代码,没有改动

    Reviewed by a1239897580 at 2022-07-28 04:29
  • 8. FairWidget接收FairProps 数据解析异常

    通过FairWidget data传递json数据,例如 { "arguments":{ "name":"测试" } }

    在fairwidget中获取传递过来的参数

    @FairProps() var data;

    // JS生命周期方法--在JS加载完成自动调用 void onLoad() { //这种写法无法获取到name字段 var name = data['arguments']['name']; //这种写法才能获取到字段 var name = data['arguments'].name; }

    Reviewed by yyzl0418 at 2022-05-31 07:30
  • 9. 不支持多个delegate

    问题 目前delegate名称必须与fairwidget名称对应,不能支持多个delegate。 fairplugin不支持dart到js的自动转化,每次需要手写js。

    预期 可以支持一个fairwidget支持多个delegate。 fairplugin支持dart到js的自动转化。 @avenwu

    Reviewed by cuocuo at 2022-08-18 03:39
  • 10. ios调用plugin方法失败:FairJSBridge.m exceptionValue:ReferenceError: Cannot access uninitialized variable.

    问题

    在ios使用plugin调用dart侧方法报错,在Android可以正常调用

    环境信息

    提供Fair版本号

    dependencies:
      fair: 2.7.0
    

    相关截图【可选】

    [Fair]:
    	File:FairDartBridge.m, 
    	Function:-[FairDartBridge setDartListener]_block_invoke, 
    	Line:87 >>
    	{"pageName":"plugin_test#0","type":"method","args":{"funcName":"_onPressed","args":null}}
    [Fair]:
    	File:FairJSBridge.m, 
    	Function:-[FairJSBridge context]_block_invoke, 
    	Line:220 >>
    	exceptionValue:ReferenceError: Cannot access uninitialized variable.
    [Fair]:
    	File:FairDartBridge.m, 
    	Function:-[FairDartBridge setDartListener]_block_invoke_2, 
    	Line:92 >>
    	undefined
    [Fair]:
    	File:FairDartBridge.m, 
    	Function:-[FairDartBridge setDartListener]_block_invoke_2, 
    	Line:96 >>
    	undefined
    
    Reviewed by CJChen98 at 2022-08-12 10:33
  • 11. flutter pub run build_runner build第三方库问题

    @FairBinding(packages: [ 'package:cached_network_image/src/cached_image_widget.dart', ])出现报错

    [SEVERE] fair_compiler:package on lib/$lib$ (cached):

    Exception: [Fair] Failed to generate widget binding from => .dart_tool/build/fairc/source No content is generated: build/fair/log/2022-08-12_16:07:035.txt [SEVERE] Failed after 37.3s pub finished with exit code 1

    image

    @FairBinding(packages: [ 'package:pull_to_refresh/scr/smart_refresher.dart', ])出现报错 AssetNotFoundException: pull_to_refresh|lib/scr/smart_refresher.dart

    image

    目前试了这两个常见的库 都出现了问题...

    Reviewed by softAlexs at 2022-08-12 08:14
  • 12. # flutter pub run build_runner build --verbose --delete-conflicting-outputs 报错

    #52 后续问题查找 [+52383 ms] "flutter run" took 52,814ms. [ +5 ms] pub finished with exit code 1 [ +1 ms] #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3) #1 _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:416:7) #2 PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:251:5) #3 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1161:27) #4 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #5 CommandRunner.runCommand (package:args/command_runner.dart:209:13) #6 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9) #7 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #8 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5) #9 run.. (package:flutter_tools/runner.dart:62:9) #10 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #11 main (package:flutter_tools/executable.dart:94:3)

    通过添加调试日志,发现两处空安全报错:

    1. flutter/.pub-cache/hosted/pub.flutter-io.cn/fair_dart2dsl-1.0.1/lib/src/widget.dart image image
    2. flutter/.pub-cache/hosted/pub.flutter-io.cn/fair_dart2dsl-1.0.1/lib/fairc.dart image
    Reviewed by interfacekun at 2022-08-08 09:50
  • 13. 运行fair的example报错

    Xcode's output: ↳ Writing result bundle at path: /var/folders/s3/pwlp8skj5b5cps6j12nr14xm0000gn/T/flutter_tools.UHbYQW/flutter_ios_build_temp_dirztajXO/temporary_xcresult_bundle

    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$c.dart:390:13: Error: No named parameter with the name 'capLeftEdge'.
                capLeftEdge: props['capLeftEdge'] ?? true,
                ^^^^^^^^^^^
    /opt/flutter/packages/flutter/lib/src/cupertino/picker.dart:354:9: Context: Found this candidate, but the arguments don't match.
      const CupertinoPickerDefaultSelectionOverlay({
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$c.dart:469:13: Error: No named parameter with the name 'maxLengthEnforced'.
                maxLengthEnforced: props['maxLengthEnforced'] ?? true,
                ^^^^^^^^^^^^^^^^^
    /opt/flutter/packages/flutter/lib/src/cupertino/text_field.dart:209:9: Context: Found this candidate, but the arguments don't match.
      const CupertinoTextField({
            ^^^^^^^^^^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$c.dart:530:13: Error: No named parameter with the name 'maxLengthEnforced'.
                maxLengthEnforced: props['maxLengthEnforced'] ?? true,
                ^^^^^^^^^^^^^^^^^
    /opt/flutter/packages/flutter/lib/src/cupertino/text_field.dart:373:9: Context: Found this candidate, but the arguments don't match.
      const CupertinoTextField.borderless({
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$w.dart:2184:44: Error: Undefined name 'Overflow'.
                overflow: props['overflow'] ?? Overflow.clip,
                                               ^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$w.dart:2184:13: Error: No named parameter with the name 'overflow'.
                overflow: props['overflow'] ?? Overflow.clip,
                ^^^^^^^^
    /opt/flutter/packages/flutter/lib/src/widgets/basic.dart:3708:3: Context: Found this candidate, but the arguments don't match.
      Stack({
      ^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$w.dart:2780:13: Error: No named parameter with the name 'autovalidate'.
                autovalidate: props['autovalidate'] ?? false,
                ^^^^^^^^^^^^
    /opt/flutter/packages/flutter/lib/src/widgets/form.dart:40:9: Context: Found this candidate, but the arguments don't match.
      const Form({
            ^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$w.dart:2797:13: Error: No named parameter with the name 'autovalidate'.
                autovalidate: props['autovalidate'] ?? false,
                ^^^^^^^^^^^^
    /opt/flutter/packages/flutter/lib/src/widgets/form.dart:262:9: Context: Found this candidate, but the arguments don't match.
      const FormField({
            ^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$w.dart:3100:47: Error: Method not found: 'DefaultTextEditingActions'.
          'DefaultTextEditingActions': (props) => DefaultTextEditingActions(
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$m.dart:336:13: Error: No named parameter with the name 'maxLengthEnforced'.
                maxLengthEnforced: props['maxLengthEnforced'] ?? true,
                ^^^^^^^^^^^^^^^^^
    /opt/flutter/packages/flutter/lib/src/material/text_field.dart:276:9: Context: Found this candidate, but the arguments don't match.
      const TextField({
            ^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$m.dart:3797:31: Error: Member not found: 'class__sharp'.
            'class__sharp': Icons.class__sharp,
                                  ^^^^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$m.dart:3798:33: Error: Member not found: 'class__rounded'.
            'class__rounded': Icons.class__rounded,
                                    ^^^^^^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$m.dart:3799:34: Error: Member not found: 'class__outlined'.
            'class__outlined': Icons.class__outlined,
                                     ^^^^^^^^^^^^^^^
    ../flutter_version/flutter_2_5_0/lib/src/widgets/$$m.dart:7351:37: Error: Member not found: 'pie_chart_outlined'.
            'pie_chart_outlined': Icons.pie_chart_outlined,
                                        ^^^^^^^^^^^^^^^^^^
    lib/best_flutter_ui/custom_drawer/drawer_user_controller.dart:70:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
     - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/opt/flutter/packages/flutter/lib/src/widgets/binding.dart').
        WidgetsBinding.instance?.addPostFrameCallback((_) => getInitState());
                       ^
    lib/best_flutter_ui/fitness_app/traning/training_screen.dart:29:28: Warning: Operand of null-aware operation '!' has type 'AnimationController' which excludes null.
     - 'AnimationController' is from 'package:flutter/src/animation/animation_controller.dart' ('/opt/flutter/packages/flutter/lib/src/animation/animation_controller.dart').
                parent: widget.animationController!,
                               ^
    lib/best_flutter_ui/fitness_app/traning/training_screen.dart:66:28: Warning: Operand of null-aware operation '!' has type 'AnimationController' which excludes null.
     - 'AnimationController' is from 'package:flutter/src/animation/animation_controller.dart' ('/opt/flutter/packages/flutter/lib/src/animation/animation_controller.dart').
                parent: widget.animationController!,
                               ^
    lib/best_flutter_ui/fitness_app/my_diary/meals_list_view.dart:47:27: Warning: Operand of null-aware operation '!' has type 'Animation<double>' which excludes null.
     - 'Animation' is from 'package:flutter/src/animation/animation.dart' ('/opt/flutter/packages/flutter/lib/src/animation/animation.dart').
              opacity: widget.mainScreenAnimation!,
                              ^
    Failed to package /Users/wuxiaoan/Desktop/flutter_dy_demo/fair/example.
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    
    Result bundle written to path:
    	/var/folders/s3/pwlp8skj5b5cps6j12nr14xm0000gn/T/flutter_tools.UHbYQW/flutter_ios_build_temp_dirztajXO/temporary_xcresult_bundle
    

    dependency_overrides: fair_version: path: ../flutter_version/flutter_2_5_0

    Reviewed by hixiaoan at 2022-08-01 15:53
  • 14. dart2dsl和json_serializable冲突

    dart2dsl中AstNodeMapBuilder没有指定generatedExtension,导致与json_serializable冲突出错。 报错:Both fair_dart2dsl:ast_node_map_builder and source_gen:combining_builder may output test/widget_test.g.dart. Potential outputs must be unique across all builders. See https://github.com/dart-lang/build/blob/master/docs/faq.md#why-do-builders-need-unique-outputs。

    Reviewed by cuocuo at 2022-07-18 07:49

Related

Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.
Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

widget_tree_depth_counter Widget Tree Depth Counter WidgetTreeDepthCounter is a simple widget to count the amount of nested widget tree, useful in the

Aug 1, 2022
🆙🚀 Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in
🆙🚀  Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in

???? Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in (with notice bar progress), supports full upgrade, hot update and incremental upgrade

Aug 12, 2022
Dec 29, 2021
A Flutter widget to dynamically add links to your text.
A Flutter widget to dynamically add links to your text.

linkable A Flutter widget to add links to your text. By default, the Text or RichText widgets render the URLs in them as simple text which are not cli

Dec 15, 2021
Dynamically themed Music Player built with flutter
Dynamically themed Music Player built with flutter

?? Flutter Music Player Contact me email: [email protected] Gitter: https://gitter.im/Moda20TuneIn/community Thank you in advance ?? Getting Started

Jul 25, 2022
A Flutter plugin than allow expand and collapse text dynamically
A Flutter plugin than allow expand and collapse text dynamically

readmore A Flutter plugin than allow expand and collapse text. usage: add to your pubspec readmore: ^1.0.2 and import: import 'package:readmore/readm

Aug 7, 2022
Flutter dynamically load translation in your app.

Flutter dynamically load translation in your app.

Apr 4, 2022
Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent.
Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent.

Polymaker Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent. Ins

Apr 17, 2022
Dynamically translate text

auto_localization A new Flutter plugin. Flutter package to dynamically translate your app. This plugin will AUTOMATICALLY detect the app Localization

Jan 27, 2022
A Flutter widget that checks and displays the version status of application and you can easily guide user to update your app
A Flutter widget that checks and displays the version status of application and you can easily guide user to update your app

A most easily usable Flutter widget about application version check! 1. About 1.

Dec 16, 2021
Flutter Insert, Update, Delete and add form view dynamic

salesapp Insert, Update, Delete and form view add dynamic. Getting Started This project is a starting point for a Flutter application. A few resources

Dec 22, 2021
App movil desarrollada en Flutter con manejo de GET POST UPDATE DELETE ,,etc con Firebase

productos_app Requerimientos : tener instalado extension de dart y flutter Emulador de android o dispositivo fisico /IOS Emulador Ejecutar : flutter r

Dec 10, 2021
Flutter App - Add Firebase Crud Operation can Create Delete Update Read real time data
Flutter App - Add Firebase Crud Operation can Create Delete Update Read real time data

Firebase-Crud-Operation In This Flutter App I Will Add Firebase Crud Operation like you can Create Delete Update Read real time data. Sample Images Re

Jul 28, 2022
Rest Api Crud funtion . Created, Update, Delete , Read

flutter_application_10 A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you s

Feb 9, 2022
The prime objective of this app is to store the real time information of the user using firebase cloud firestore and also can delete, remove and update the customer information

crud_firestore A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started i

Mar 15, 2022
This is the latest update

elandguard A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Nov 26, 2021
Implementing simple storage operations, CRUD (Create, Read, Update, Delete), using Firebase Firestore
Implementing simple storage operations, CRUD (Create, Read, Update, Delete), using Firebase Firestore

CRUD Firebase Implementing simple storage operations, CRUD (Create, Read, Update

Jul 28, 2022
Feb 2, 2022