Mohammad alqannas
Mohammad alqannas

Reputation: 425

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

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

Upvotes: 0

Views: 225

Answers (2)

Ravindra S. Patil
Ravindra S. Patil

Reputation: 14775

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);

Upvotes: 0

greetal
greetal

Reputation: 1537

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

Upvotes: 1

Related Questions