In todays video we went over a rather simple way to use the TextFormField widget as well as as use the data that is created every time the user types something in it.

As requested I will be posting the code on my website so you can check it out and copy it.

Full code example:

import 'package:circles/utils/Database.dart';
import 'package:circles/widgets/bottomNavBar.dart';
import 'package:flutter/material.dart';

class PreferencesScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return PreferencesScreenState();
  }
}

class PreferencesScreenState extends State<PreferencesScreen> {
  Future userFuture;

  String name = 'hey';

  @override
  void initState() {
    super.initState();
    userFuture = _getUser();
  }

  _getUser() async {
    return await DBProvider.db.getUser();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        automaticallyImplyLeading: false,
        title: Text('Preferences'),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            Text('$name'),
            TextFormField(
              initialValue: name,
              onChanged: (text) {
              setState(() {
                name = text;
              });
              print('name: $name');
            },)
          ],
        ),
      ),
      bottomNavigationBar: BottomNavBar(),
    );
  }
}