Created
June 2, 2020 21:05
-
-
Save r3dm1ke/749d98084ca11d63d10c483729840883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CounterPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final CounterBloc counterBloc = BlocProvider.of<CounterBloc>(context); | |
return Scaffold( | |
appBar: AppBar(title: Text('BLoC Demo')), | |
body: BlocBuilder<CounterBloc, int>(builder: (context, count) { | |
return Center( | |
child: | |
Column(mainAxisAlignment: MainAxisAlignment.center, children: [ | |
Text('$count', style: TextStyle(fontSize: 32.0)), | |
RaisedButton( | |
child: Icon(Icons.add), | |
onPressed: () { | |
counterBloc.add(CounterEvent.increment); | |
}), | |
RaisedButton( | |
child: Icon(Icons.remove), | |
onPressed: () { | |
counterBloc.add(CounterEvent.decrement); | |
}) | |
])); | |
}), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment