'How to add a null value on a list of <Offsets>? null cant be added because flutter null safety
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!);});}
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Diwyansh |
