I have been working on this issue for hours. The problem is that if i create a new flutter project add this line of code.
return Container(child: ElevatedButton(child: Text("ccc"),onPressed: (){
Get.defaultDialog(
title: "GeeksforGeeks",
middleText: "Hello world!",
backgroundColor: Colors.green,
titleStyle: TextStyle(color: Colors.white),
middleTextStyle: TextStyle(color: Colors.white),
);
},),);
I am getting this error.
Null check operator used on a null value
I have tried reinstal package and other things(flutter doctor,pub get,flutter clean).But the problem persists.
CodePudding user response:
I tried it and I noticed the user has to use "GetMaterialApp" instead of "MaterialApp". After you replace you could get what you expect to have.
Widget build(BuildContext context) {
return MaterialApp(
After
Widget build(BuildContext context) {
return GetMaterialApp(
Fig2. The error I got before replacing "MaterialApp" with "GetMaterialApp"
Fig3. the picture I got after changed. It works.