fair 2.4.1 copy "fair: ^2.4.1" to clipboard
fair: ^2.4.1 copied to clipboard

outdated

Flutter Fair is a package used to update widget dynamically.

example/lib/main.dart

/*
 * Copyright (C) 2005-present, 58.com.  All rights reserved.
 * Use of this source code is governed by a BSD type license that can be
 * found in the LICENSE file.
 */

import 'dart:convert';

import 'package:fair/fair.dart';
import 'package:fair_example/src/page/home_page.dart';
import 'package:fair_example/src/page/logic-page2page/sample_logic_page2page.dart';
import 'package:fair_example/src/page/logic_home_page.dart';
import 'package:fair_example/src/page/modules.dart';
import 'package:fair_example/src/page/plugins/net/fair_net_plugin.dart';
import 'package:fair_example/src/page/plugins/permission/fair_permission_plugin.dart';
import 'package:fair_example/src/page/plugins/pick-image/fair_take_photo.dart';
import 'package:flutter/material.dart';
import 'src/proxy/list_proxy.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  FairApp.runApplication(
    _getApp(),
    plugins: {
      'FairNet': FairNet(),
      'WBPermission': WBPermission(),
      'FairPhotoSelector': FairPhotoSelector(),
    },
  );
}

dynamic _getParams(BuildContext context, String key) =>
    (ModalRoute.of(context)?.settings.arguments is Map) ? (ModalRoute.of(context)?.settings.arguments as Map)[key] : null;

dynamic _getData(BuildContext context, String name) {
  var data = Map.from((ModalRoute.of(context)?.settings.arguments as Map)['data']);
  data.addAll({'pageName': name});
  return data;
}

dynamic _getApp() => FairApp(
      modules: {
        ShowFairAlertModule.tagName: () => ShowFairAlertModule(),
      },
      delegate: {
        'ListLoadMore': (ctx, _) => ListDelegate(),
      },
      child: MaterialApp(
        home: LogicHomePage(),
        routes: {
          'native_page': (context) => SampleLogicPage2Page(_getData(context, _getParams(context, 'name'))),
          // 测试Fair跳转原生使用
          'fair_page': (context) => FairWidget(
              name: _getParams(context, 'name'),
              path: _getParams(context, 'path'),
              data: {'fairProps': jsonEncode(_getData(context, _getParams(context, 'name')))}),
        },
      ),
    );
41
likes
0
pub points
63%
popularity

Publisher

verified publisherhacktons.cn

Flutter Fair is a package used to update widget dynamically.

Homepage

License

unknown (license)

Dependencies

fair_annotation, fair_version, ffi, flat_buffers, flutter, http, url_launcher

More

Packages that depend on fair