使用flutter打开一个老项目的时候遇到一个问题,map里面的值想使用++实现自增,结果新版flutter报错,爆红的是两个加号。
final _productsInCart = <int, int>{};
_productsInCart[productId]+
暂时使用普通的方法来写了,然后判空
_productsInCart[productId] = (_productsInCart[productId])!+1
暂时不报错了。
不知道各位有没有更好的办法
使用flutter打开一个老项目的时候遇到一个问题,map里面的值想使用++实现自增,结果新版flutter报错,爆红的是两个加号。
final _productsInCart = <int, int>{};
_productsInCart[productId]+
暂时使用普通的方法来写了,然后判空
_productsInCart[productId] = (_productsInCart[productId])!+1
暂时不报错了。
不知道各位有没有更好的办法