Skip to content

Instantly share code, notes, and snippets.

@itsatifsiddiqui
Created May 10, 2019 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsatifsiddiqui/6bdbdcc54419984764f713e2b5e0be2b to your computer and use it in GitHub Desktop.
Save itsatifsiddiqui/6bdbdcc54419984764f713e2b5e0be2b to your computer and use it in GitHub Desktop.
Child widget
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final counter = Provider.of<Counter>(context);
return Scaffold(
appBar: AppBar(
title: Text("Provider Demo"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'${counter.getCounter()}',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
FloatingActionButton(
onPressed: counter.increment,
tooltip: 'Increment',
child: Icon(Icons.add),
),
SizedBox(height: 10),
FloatingActionButton(
onPressed: counter.decrement,
tooltip: 'Increment',
child: Icon(Icons.remove),
)
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment