'Rx<Future<List<SectionsDBStat>>*>*' 类型的值不能分配给类型的变量

A value of type 'Rx<Future<List<SectionsDBStat>>*>*' can't be assigned to a variable of type

我正在学习 Flutter 和 GetX。 我有型号:

class SectionsDBStat {

  int notificationsTotalCount;
  int notificationsWaitingForProcessing;
  DateTime notificationsLastArchiveDate;

  SectionsDBStat({
    required this.notificationsTotalCount,
    required this.notificationsWaitingForProcessing,
    required this.notificationsLastArchiveDate
    });

  factory SectionsDBStat.fromJson(Map<String, dynamic> json)  {
      return SectionsDBStat(
        notificationsTotalCount: json['notificationsTotalCount'],
        notificationsWaitingForProcessing: json['notificationsWaitingForProcessing'],
        notificationsLastArchiveDate: DateTime.parse(json['notificationsLastArchiveDate'])
      );

    }  

}

我正在尝试创建从 http:

接收数据的 Getx 控制器
class SectionsStatController extends GetxController {
    
    SectionsDBStat sectionsDBStat = Future.value(<SectionsDBStat>).obs;

    getStat() async {
      var value = await http.get('${url}/stat?total');
      if(value.statusCode == 200) {
          Map<String, dynamic> valueMap = jsonDecode(value.body)['data'];
          sectionsDBStat = SectionsDBStat.fromJson(valueMap);
          update();
      } else {
        print("Can't get stat: ${value.statusCode}");
      }

    }

}

我遇到一个错误:

A value of type 'Rx<Future<List<SectionsDBStat>>*>*' can't be assigned to a variable of type 'SectionsDBStat'.

所以我应该使用另一种类型。但是什么?我试过 final 但出现错误:

'sectionsDBStat' can't be used as a setter because it's final.

我不知道你为什么要使用 Future,在这里你试图将 Rx<Future<List<SectionsDBStat>>*> 分配给 sectionsDBStat 但这是不可能的

替换此行

SectionsDBStat sectionsDBStat = Future.value(<SectionsDBStat>).obs;

有了这个

final sectionsDBStat = SectionsDBStat().obs;

然后这样赋值

sectionsDBStat.value = SectionsDBStat.fromJson(valueMap);