Created
November 13, 2019 16:36
-
-
Save awaik/a5848a2450a702c374b73293c2e1d120 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 MyHomePage extends StatelessWidget { | |
CounterBloc counterBloc = CounterBloc(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: StreamBuilder<int>( | |
stream: counterBloc.pressedCount, | |
builder: (context, snapshot) { | |
return Text( | |
'Flutter Counter Bloc Example - ${snapshot.data.toString()}', | |
); | |
}), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text( | |
'You have pushed the button this many times:', | |
), | |
StreamBuilder<int>( | |
stream: counterBloc.pressedCount, | |
builder: (context, snapshot) { | |
return Text( | |
'${snapshot.data.toString()}', | |
style: Theme.of(context).textTheme.display1, | |
); | |
}), | |
], | |
), | |
), | |
floatingActionButton: Container( | |
width: 100.0, | |
height: 100.0, | |
child: FloatingActionButton( | |
onPressed: () { | |
counterBloc.incrementCounter.add(null); | |
}, | |
tooltip: 'Increment', | |
child: Text( | |
"+ \n send \n to BLoC", | |
textAlign: TextAlign.center, | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment