Because I want to call the setState Method in the class "EditProfilePage", I had to change it to a statefulWidget:
class EditProfilePage extends StatefulWidget {
@override
_EditProfilePageState createState() => _EditProfilePageState();
}
class _EditProfilePageState extends State<EditProfilePage> {
TextEditingController nameController = new TextEditingController();
TextEditingController bioController = new TextEditingController();
File file;
.
.
.
applyChanges() {
Firestore.instance
.collection('insta_users')
.document(currentUserModel.id)
.updateData({
"displayName": nameController.text,
"bio": bioController.text
});
}
}
But now, my class 'Profile_page' seems to miss the method "applyChanges()" of "EditProfilePage" and throws following error:
The method 'applyChanges' isn't defined for the class 'EditProfilePage'.
Here is the method in 'Profile_Page', which calls applyChanges() from 'EditProfilePage':
editProfile() {
EditProfilePage editPage = new EditProfilePage();
Navigator.of(context)
.push(new MaterialPageRoute<bool>(builder: (BuildContext context) {
return new Center(
child: new Scaffold(
appBar: new AppBar(
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () {
Navigator.maybePop(context);
},
),
title: new Text('Edit Profile',
style: new TextStyle(
color: Colors.black, fontWeight: FontWeight.bold)),
elevation: 1.0,
backgroundColor: Colors.white,
actions: <Widget>[
new IconButton(
icon: new Icon(
Icons.check,
color: Colors.blueAccent,
),
onPressed: () {
editPage.applyChanges();
Navigator.maybePop(context);
})
Any suggestions on how to fix this problem? I did not forget to import.
Btw I am very new to flutter and just trying to understand dart. Best Regards!