closure_widget_builder 0.1.2

Flutter Android iOS web

A builder that is as easy to build widgets as hooks.

ClosureWidgetBuilder #

A builder that is as easy to build widgets as hooks.

Get start #

Build the same sample application as flutter. But no boilerplate code, more efficient work

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

main() => runApp(app());

app() => MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: myHomePage(title: 'Flutter Demo Home Page'),
    );

myHomePage({String title}) => ClosureWidgetBuilder(
      builder: (context, notify, dispose) {
        var counter = 0;

        incrementCounter() {
          notify(() => ++counter);
        }

        return () => homeScaffold(context, title, counter, incrementCounter);
      },
    );

homeScaffold(context, title, counter, incrementCounter) => Scaffold(
      appBar: AppBar(title: Text(title)),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('You have pushed the button this many times:'),
            Text('$counter', style: Theme.of(context).textTheme.display1),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
0
likes
90
pub points
0%
popularity

A builder that is as easy to build widgets as hooks.

Homepage

Documentation

API reference

Uploader

huazhou19@gmail.com

License

Apache 2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on closure_widget_builder