I'm designing a mobile Application ,it looks like "WhatsApp" I initiate class called "chat model"
when i run app it gives me "Null safety error or null checker" I want to display the name of person
please advice me to solve this problem
class Chat Model { */my code in chat model class
String? name;
String? icon;
bool? is group;
String? time;
String? current message;
Chat Model(
{this.name, this. icon, this.is group, this. time, this. current message});
}
class chatpage extends StatefulWidget { */ my code in chat page
const chatpage({super.key});
@override
State<chatpage> createState() => _chatpageState();
}
// ignore: camel_case_types
class _chatpageState extends State<chatpage> {
List<ChatModel> chats = [
ChatModel(
name: "Ahmed omar",
icon: "person.svg",
isgroup: false,
time: "10:00",
currentmessage: "Hi Ahmed"),
ChatModel(
name: "Hussien Mohamed",
icon: "person.svg",
isgroup: true,
time: "10:00",
currentmessage: "Hi everyone"),
ChatModel(
name: "Hussien omar",
icon: "person.svg",
isgroup: false,
time: "10:00",
currentmessage: "Hi Hussien"),
ChatModel(
name: "Hussien omar",
icon: "person.svg",
isgroup: true,
time: "10:00",
currentmessage: "Hi everyone"),
];
*/ error here
Text(
widget.chatModel!.name,
style: TextStyle(
fontSize: 18.5,
fontWeight: FontWeight.bold,
),