relay 0.0.2 copy "relay: ^0.0.2" to clipboard
relay: ^0.0.2 copied to clipboard

outdated

A new Flutter package project.

relay #

A new Flutter package project.

Example #

enum ExampleUpdate { counter, name }

class ExampleStation extends Station<ExampleUpdate> {
  int counter = 0;
  String name = '';

  void increment() {
    counter++;
    relay(ExampleUpdate.counter);
  }

  void updateName(String text) {
    name = text;
  }
}

class Example extends StatefulWidget {
  ExampleState createState() => ExampleState();
}

class ExampleState extends State<Example> {
  ExampleStation station;

  @override
  void initState() {
    super.initState();
    station = ExampleStation();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Center(
          child: Column(
            children: <Widget>[
              RelayBuilder<ExampleStation, ExampleUpdate>(
                station: station,
                observers: [ExampleUpdate.counter],
                builder: (context, station) => Text('${station.counter}'),
              ),
              RelayBuilder<ExampleStation, ExampleUpdate>(
                station: station,
                observers: [ExampleUpdate.name, ExampleUpdate.counter],
                builder: (context, station) =>
                    Text('${station.name} : ${station.counter}'),
              ),
              TextField(
                onChanged: station.updateName,
                decoration: InputDecoration(
                  labelText: 'Name',
                ),
              )
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: station.increment,
        child: Icon(Icons.add),
      ),
    );
  }
}
3
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter package project.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on relay