Reputation: 21
I'm creating a drawing app using flutter. I've used gesturedetector onpanstart, onpanend, onpanupdate. But I have to close the array of offsets. Because of null safety I am not able to use 'null'. how can I add a null value on the List or end up the list somehow. or any other ways to make a drawing app using flutter.
onPanEnd:(details){setState((){drawingPoints.add(null!);});}
Upvotes: 2
Views: 2025
Reputation: 1
You can copy what you did with onPanStart , onPanUpdate , but in theonPanEnd instead of writing details.globalPosition just write Offset.infinite
Upvotes: 0
Reputation: 3514
To clear the available data in your List
use .clear()
or to assign a null
value simply assign null to it
onPanEnd:(details){setState((){drawingPoints = null;});} // to assign null
onPanEnd:(details){setState((){drawingPoints.clear();});} // to clear the data
Upvotes: 0