A value of type 'RenderObject?' can't be assigned to a variable of type 'RenderBox'.
Try changing the type of the variable, or casting the right-hand type to 'RenderBox'
错误的提示是产生了从 dynamic 到 RenderBox 的不正确的隐式转换,隐式转换失败了。解决方案是在报错的位置人为进行强转:
RenderBox referenceBox = context.findRenderObject()
修改成
RenderBox referenceBox = context.findRenderObject() as RenderBox;