Flutter Dart-在StreamSubscription中接收非静态成员var

时间:2019-02-05 15:55:53

标签: dart flutter

我需要保存以下通过非静态成员变量_uid的StreamSubscription的结果。这是不允许的。有什么解决方法可以使这项工作?

StreamSubscription < LocationResult > subscription = Geolocation.locationUpdates(

    accuracy: LocationAccuracy.best,
    displacementFilter: 10.0, // in meters
    inBackground: true, // by default, location updates will pause when app is inactive (in background). Set to `true` to continue updates in background.
  )
  .listen((result) {
    if (result.isSuccessful) {

      saveResult(result, _uid);
    } else {

    }
  });

_uid是在小部件构建期间设置的:

String _uid = UserModel.of(context).firebaseUser.uid;

由于它是静态方法,我也无法在saveResult()中访问_uid。

0 个答案:

没有答案