'pre decrement operator not working in dart null safety

if (cart.quantity! > 1) {
  --cart.quantity;

enter image description here

this block of code works in previous flutter version after migrate to null safety it's not working anymore. How to properly write pre decrement operator in dart null safety



Solution 1:[1]

    if (cart.quantity! > 1) {
  cart.quantity = cart.quantity! - 1}

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 Jarvis098