From the course: Flutter Essential Training: Build for Multiple Platforms

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Calling a parent class method from child class

Calling a parent class method from child class - Flutter Tutorial

From the course: Flutter Essential Training: Build for Multiple Platforms

Calling a parent class method from child class

- [Instructor] So, now we have a bunch of default messages every time we run the app and render this screen, but what about adding a new message to this list every time it is typed by the user? The idea is to add a message from this chat input widget and append it to the end of this list. So, whenever the Send button is tapped, which is where we have this method being invoked, we want to create a ChatMessageEntity object first and append it back to our list. So, let's just create that object, so newChatMessage, which will be a ChatMessageEntity, and it will invoke the normal constructor because we do not have a JSON here. And this text will just be the text controller's text, so ChatMessageEntity.text. And ID could be anything. For now let's just imagine it's, I don't know, 244. CreatedAt will be the time, so DateTime.now, and convert it to millisecondsSinceEpoch. And author, we will make sure the author right now is…

Contents