Home > Enterprise >  The getter 'key' was called on null. Receiver: null Tried calling: key
The getter 'key' was called on null. Receiver: null Tried calling: key

Time:12-17

I am using version sdk: ">=2.7.0 <3.0.0" I had a problem with the key enter image description here

CodePudding user response:

you can use ? null safe as : This is only example how could you use it:

child: Column(
            children: <Widget>[
              Consumer<UserProvider>(builder: (context, model, child) {
                final userData = model.userModels;
                return userData == null
                    ? Container()
                    : Row(
                        children: <Widget>[
                          Container()
 ])})])

for more you can refer here

CodePudding user response:

Try below code hope its helpful to you. add null check to Key

Refer null safety here and here

const CategoriesScreen({Key? key}) : super(key: key);
  • Related