Flutter Convert FromMap to list 参数类型'Object?'无法赋值给参数类型'Map<String, dynamic>'

Flutter Convert FromMap to list The argument type 'Object?' can't be assigned to the parameter type 'Map<String, dynamic>'

我正在尝试在 flutter 中创建一些图表,但我陷入了困境 DocumentSnapshot.data 我觉得 flutter 已经更改了命名但我无法在任何地方找到它。

Widget _buildBody(BuildContext context){
    return StreamBuilder<QuerySnapshot>(
       stream: FirebaseFirestore.instance.collection('sales').snapshots(),
      builder: (context,snapshot){
        if(!snapshot.hasData){
          return LinearProgressIndicator();
        }
          else{

           
                 List<Sales> sales = snapshot.data!.docs
          .map((snapshot) => Sales.fromMap(snapshot.data()))
          .toList();
          }
      },
      
      );
  }

你会尝试像下面这样改变吗?

来自

Sales.fromMap(snapshot.data())

Sales.fromMap(snapshot.data() as Map<String, dynamic>)