Last active
April 11, 2021 11:40
-
-
Save PeterHdd/7700b230e2c923df3dec5f3aec6b30a2 to your computer and use it in GitHub Desktop.
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 characters
class _MyHomePageState extends State<MyHomePage> { | |
final fb = FirebaseDatabase.instance; | |
final myController = TextEditingController(); | |
final name = "Name"; | |
@override | |
Widget build(BuildContext context) { | |
final ref = fb.reference(); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Container( | |
child: Column( | |
children: <Widget>[ | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Text(name), | |
SizedBox(width: 20), | |
Expanded(child: TextField(controller: myController)), | |
], | |
), | |
ElevatedButton( | |
onPressed: () { | |
ref.child(name).set(myController.text); | |
}, | |
child: Text("Submit"), | |
), | |
], | |
))); | |
} | |
@override | |
void dispose() { | |
// Clean up the controller when the widget is disposed. | |
myController.dispose(); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment