android “setup”已弃用,不应使用,请使用PurchasesConfiguration

hc8w905p  于 2023-02-10  发布在  Android
关注(0)|答案(1)|浏览(99)

我怎样才能修复这个问题并使其不被弃用

import 'package:purchases_flutter/purchases_flutter.dart';
class PurchaseApi{
  static const _apiKey = '';
  static Future init() async{
    await Purchases.setDebugLogsEnabled(true);
    await Purchases.setup(_apiKey);
  }

  static Future<List<Offering>> fetchOffers() async {
   try{
    final offerings = await Purchases.getOfferings();
    final current = offerings.current;
    return current == null ? [] : [current];
  } on PlatformException catch (e) {
      return [];
    }
  }
}

我已经改变了第一次等待购买。setLogLevel(真为LogLevel);但是当我改变设置的时候,我得到了一个错误。错误是方法'PurchasesConfiguration'没有为类型'Purchases'定义。我已经尝试导入'package:purchases_flutter/models/purchases_configuration. dart';

tquggr8v

tquggr8v1#

enter image description here
当您将鼠标悬停在弃用的安装方法上时,会看到一条提示
替换:来自

await Purchases.setup(_apiKey);

PurchasesConfiguration(_apiKey);

相关问题