该问题与我之前的问题有关:Why can't I use context.read in build(), but I can use Provider.of with listen: false?
您说过旧的Provider.of<X>(context, listen: false)
语法是不安全的。但是,它有效。
我相信fetchTransactions()
的方法不会改变,因此无需观看。
我不能使用context.read
,因为它不在闭包中,并且会引发“不要使用context.read在构建方法中”错误。
我不能将context.watch
或context.select
与FutureBuilder
一起使用,因为这将导致无限的重建循环。