Last active
November 3, 2020 04:45
-
-
Save chimon2000/ad89d1656f4ce8164eafc7f086182a81 to your computer and use it in GitHub Desktop.
Revisions
-
chimon2000 revised this gist
Nov 3, 2020 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class _BinderPageState extends State<BinderPage> { @override Widget build(BuildContext context) { // Subscribe to NotesState final state = context.watch(notesRef); return Scaffold( @@ -33,12 +34,16 @@ class _BinderPageState extends State<BinderPage> { children: [ FlatButton( onPressed: () { // Get a reference of NotesViewLogic // and add a note. context.use(notesViewLogicRef).addNote(); _controller.clear(); }, child: Text('Create Note')), TextField( controller: _controller, // Get a reference of NotesViewLogic // and update the input value. onChanged: (value) => context.use(notesViewLogicRef).updateInput(value), decoration: InputDecoration.collapsed(hintText: 'Add a note'), -
chimon2000 created this gist
Nov 1, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ class BinderPage extends StatefulWidget { const BinderPage({Key key}) : super(key: key); @override _BinderPageState createState() => _BinderPageState(); } class _BinderPageState extends State<BinderPage> { TextEditingController _controller; @override void initState() { super.initState(); _controller = TextEditingController(); } @override void dispose() { _controller?.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final state = context.watch(notesRef); return Scaffold( appBar: AppBar(title: Text('My notes app')), body: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ FlatButton( onPressed: () { context.use(notesViewLogicRef).addNote(); _controller.clear(); }, child: Text('Create Note')), TextField( controller: _controller, onChanged: (value) => context.use(notesViewLogicRef).updateInput(value), decoration: InputDecoration.collapsed(hintText: 'Add a note'), ), Divider(), Expanded( child: ListView.builder( itemBuilder: (context, index) => Note(text: state.notes[index]), itemCount: state.notes.length, ), ) ], ), ), ); } }