When i am trying to use drawer without app bar i am taking this error.
error: The method 'openDrawer' can't be unconditionally invoked because the receiver can be 'null'.
I tried bunch of solutions but none of them worked.
You can use Scaffold.of(context).openDrawer()
, if you are putting it in the same widget use Builder
.
child: Builder(
builder: (context) {
return IconButton(
icon: const Icon(
CupertinoIcons.text_alignleft,
size: 30,
color: Colors.white,
),
onPressed: () => Scaffold.of(context).openDrawer(),
);
},
),
```