var_widget 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 46

var_widget #

A new state manangment for flutter

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.2.0] - 2019/05/06 #

  • Added Settable
  • Added some widgets including VarText and VarCheckbox

[0.1.1] - 2019/04/28 #

  • VarWidget now rebuilds when Var itself is changed.

[0.1.0] - 2019/04/25 #

  • Var does not implement Sink

[0.0.4] - 2019/04/24 #

  • Fix invalid access while printing debug information.

[0.0.3] - 2019/04/24 #

  • Removes invalid access.

[0.0.1] - 2019/04/23 #

  • Initial release


import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:var_widget/var_widget.dart';

import 'util.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
      home: MyHomePage(),

class MyHomePage extends StatefulWidget {
  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  List<Var<int>> vars;
  Var<int> idx;

  void initState() {

    vars = List.generate(15, (i) => new Var(0, debugLabel: 'Var $i'));
    idx = new Var(0, debugLabel: 'index');

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('var_widget'),
      body: Column(
        children: <Widget>[
            padding: EdgeInsets.only(top: 10),
            height: 150,
            child: ListView.builder(
              itemCount: vars.length,
              scrollDirection: Axis.horizontal,
              itemBuilder: (BuildContext context, int i) {
                final Color randColor = RandomColor().randomColor();

                return Container(
                  margin: const EdgeInsets.symmetric(horizontal: 8.0),
                  width: 100,
                  color: randColor,
                  child: GestureDetector(
                    child: Card(
                      color: randColor,
                      child: Center(
                        child: VarBuilder<int>(
                          value: vars[i],
                          builder: (BuildContext context, int v, Widget child) => Text('$v'),
                    onTap: () => idx.value = i,
            child: VarBuilder<int>(
              value: idx,
              builder: (BuildContext context, int idx, Widget child) {
                return SizedBox(
                  width: 200,
                  height: 200,
                  child: InkWell(
                    child: Card(
                      child: Center(
                        child: VarBuilder<int>(
                          value: vars[idx],
                          builder: (BuildContext context, int v, Widget child) {
                            return Text(
                              style: Theme.of(context).textTheme.display1,
                      color: Colors.blueAccent,
                    onTap: () => vars[idx].value++,

Use this package as a library

1. Depend on it

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

  var_widget: ^0.2.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:var_widget/var_widget.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 Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/src/value.dart.

Run flutter format to format lib/src/value.dart.

Format lib/src/widget_base.dart.

Run flutter format to format lib/src/widget_base.dart.

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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
meta ^1.1.6 1.1.8
Transitive dependencies
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies