I'm still learning flutter new this week, seems the course is outdated, so i struggle every time I face null safety errors. Now, I can't use showbottomsheet.. tried null check(!) but onPressed() is always returning null , i can't figure what should i do to prevent that..
Error: The method 'showBottomSheet' can't be unconditionally invoked because the receiver can be 'null'.
and when i use null check: it says "can't use null operand"
here's the piece of code i use:
var scaffoldkey = GlobalKey<ScaffoldState>();
onPressed: () {
scaffoldkey.currentState.showBottomSheet(
(context) => Container(
color: Colors.red,
padding: EdgeInsets.all(
20.0,
),
),
);
},