flib_live_data 1.0.0

About #

一个用来管理数据的库,可以设置观察者监听某个数据的变化,当生命周期销毁后自动移除观察者
关于生命周期分发的库,可以参考这里

Install #

  • git
  flib_live_data:
    git:
      url: git://github.com/zj565061763/flib_live_data
      ref: 1.0.0
  • pub
  dependencies:
    flib_live_data: ^1.0.0

Example #

// 创建LiveData
final FLiveData<int> number = FLiveData(0);

// 赋值
number.value = 1;

// 添加观察者,监听值的变化
number.addObserver((value) {}, this);
  /// 添加观察者
  ///
  /// - [observer] 观察者
  /// - [lifecycleOwner] 观察者要绑定的生命周期
  ///   1. [lifecycleOwner] != null,则[FLifecycleEvent.onDestroy]事件后,会自动移除观察者
  ///   2. [lifecycleOwner] == null,则不会自动移除观察者
  /// - [notifyAfterAdded] 添加观察者之后,如果[_value]不为null的话是否立即通知当前添加的观察者,默认true
  /// - [notifyLazy] 延迟通知策略,是否生命周期状态大于等于[FLifecycleState.started]之后才通知,默认false
  void addObserver(
    FLiveDataObserver<T> observer,
    FLifecycleOwner lifecycleOwner, {
    bool notifyAfterAdded = true,
    bool notifyLazy = false,
  })

  /// 移除观察者
  ///
  /// - [observer] 要移除的观察者
  void removeObserver(Function observer)

[1.0.0] - 2019.05.16

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flib_live_data: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flib_live_data/flib_live_data.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
11
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and flib_live_data.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flib_lifecycle ^1.0.0 1.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin