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 - 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
-
-
-
-
-
-
-
Organizing the styles and colors for the login page9m 9s
-
(Locked)
Organizing the styles and colors for the chat page4m 15s
-
(Locked)
Understanding the anatomy of a pubspec.yaml file5m 4s
-
(Locked)
Exploring pub.dev3m 24s
-
(Locked)
Plugins vs. packages2m 22s
-
(Locked)
Adding plugins to your app from pub.dev4m 29s
-
(Locked)
Adding packages from external sources6m 35s
-
(Locked)
Modeling entities in Dart7m 2s
-
(Locked)
Generics in Dart10m 40s
-
(Locked)
JSON: Serialization vs. deserialization2m 16s
-
(Locked)
Reading data from a JSON file13m 25s
-
(Locked)
Improving UI with box constraints4m 42s
-
(Locked)
Calling a parent class method from child class4m 30s
-
-
-
-