easy_model 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71



đŸ’ŧ easy_model #

support Flutter Web pub package demo

A simple flutter state management package, supporting local state management and global state management

  • support initState() and dispose()
  • Support global access to Model objects

🚀 Getting Started #

Before the introduction, you can have a try for Online Demo

🔑 Useage #

First define your Model object

class YourModel extends Model {
  void initState() {...}

  void dispose() {...}

  int value = 0;

When you want to use it in combination with a Widget or Page, you can do like this

  childBuilder: (ctx, model) => YourWidgetOrPage(),
  modelBuilder: () => YourModel(),

🔄 Get data and refresh #

get data

final model = ModelGroup.findModel<YourModel>();



📃 Same pages and models #

If you have the following usage scenarios

Using ModelGroup.findModel <T> () is unable to get the Model object corresponding to eachPage

Then you can use ModelGroup.findModelByKey <T> (modelKey) to obtain the corresponding Model, but it should be noted that a different modelKey must be specified when creatingModelWidget

  childBuilder: (ctx, model) => YourWidgetOrPage(),
  modelBuilder: () => YourModel(),
  modelKey: 'YourModelKey'

///get model
final model = ModelGroup.findModelByKey<YourModel>('YourModelKey');

đŸĻ‹ Partial refresh #

With the new ModelWidget and the new Model, you can achieve the effect of partial refresh, but if you think that Model is created too frequently, then you can use PartModelWidget to achieve partial refresh

  childBuilder: (ctx, model) => YourWidgetOrPage(),
  modelBuilder: () => YourModel(),
  modelKey: 'YourModelKey'

class YourWidgetOrPage extends StatelessWidget{

  Widget build(BuildContext context) {
      return Column(
          children: <Widget>[
              childBuilder: (ctx,YourModel model) => ChildThree(),
              partKey: 'YourKey',

In the above example, if you want to refresh ChildThree() separately, you can achieve it by calling the following method


This avoids frequent creation of Model. If multiple PartModelWidget correspond to the same partKey, they can be refreshed together every time they are refreshed!

🤗 Welcome for issue and pr #

Click here to create an issue

Click here to submit a pull request (please submit pr by forking the dev branch)

[1.0.1] - 2020.7.12 #

  • add PartModelWidget so you can refresh part of a widget without a new Model

[1.0.0] - 2020.5.25 #

  • Complete version 1.0.0 of this package


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

import 'model/all_model.dart';
import 'pages/all_pages.dart';

void main() {

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return ModelWidget<GlobalModel>(
      childBuilder: (context, model) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(brightness: model.brightness),
          home: PageOne(),
      modelBuilder: () => GlobalModel(),

Use this package as a library

1. Depend on it

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

  easy_model: ^1.0.1

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:easy_model/easy_model.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart


  • easy_model that is a package requiring null.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies