Estou com o mesmo problema porém já alterei para StatefulWidget e não resolveu.
import 'package:baytebank/database/app_database.dart';
import 'package:baytebank/models/contact.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ContactForm extends StatefulWidget {
@override
_ContactFormState createState() => _ContactFormState();
}
class _ContactFormState extends State<ContactForm> {
final TextEditingController _nameController = TextEditingController();
final TextEditingController _accountNumberController =
TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('New Contact'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: TextField(
controller: _nameController,
decoration: InputDecoration(labelText: 'Full name'),
style: TextStyle(
fontSize: 24.0,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: TextField(
controller: _accountNumberController,
decoration: InputDecoration(labelText: 'Account number'),
style: TextStyle(
fontSize: 24.0,
),
keyboardType: TextInputType.number,
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: SizedBox(
width: double.maxFinite,
child: RaisedButton(
child: Text('Create'),
onPressed: () {
final String name = _nameController.text;
final int accountNumber =
int.tryParse(_accountNumberController.text);
final Contact newContact = Contact(0, name, accountNumber);
save(newContact).then((id) => Navigator.pop(context));
},
),
),
)
],
),
),
);
}
}