gpt4 book ai didi

firebase - 未为类定义方法 'allowInterop'…尝试使用Firestore时Dart控制台应用程序错误

转载 作者:行者123 更新时间:2023-12-03 02:56:59 24 4
gpt4 key购买 nike

我正在尝试编写一个使用Firestore数据库作为持久层的控制台Dart App,但是当我尝试运行基本示例时,firebase会抛出这种内部库错误:

file:///home/alexandre/.pub-cache/hosted/pub.dartlang.org/firebase-5.0.2/lib/src/auth.dart:274:25: Error: The method 'allowInterop' isn't defined for the class '#lib1::Auth'.
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
var nextWrapper = allowInterop((firebase_interop.UserJsImpl user) {

我的pubspec.yaml是:
name: flix_backend_dart
description: A sample command-line application.
# version: 1.0.0
# homepage: https://www.example.com
# author: alexandre <email@example.com>

environment:
sdk: '>=2.1.0 <3.0.0'

#dependencies:
# path: ^1.4.1

dev_dependencies:
test: ^1.0.0
firebase: ^5.0.0

App的代码段为:
import 'package:firebase/firebase.dart';
import 'package:flix_backend_dart/domain/repository.dart';
import 'package:flix_backend_dart/network/load_movies.dart';
import 'package:flix_backend_dart/network/service.dart';




main(List<String> arguments) {
const _query = 'get:new21';
const _startYear = 1900;
const _endYear = 2019;
const _startNetflixRate = 0.0;
const _endNetflixRate = 5.0;
const _startImdbRate = 0.0;
const _endImdbRate = 10.0;
const _genreId = 0;
const _vtype = 'movie';
const _audio = 'Any';
const _subtitle = 'Any';
const _imdbVotes = 100;
const _downloadable = '';

final queryParameters = {
'q':
'${_query}-!${_startYear},${_endYear}-!${_startNetflixRate},${_endNetflixRate}-!${_startImdbRate},${_endImdbRate}-!${_genreId}-!${_vtype}-!${_audio}-!${_subtitle}-!${_imdbVotes}-!${_downloadable}',
't': 'ns',
'cl': '29',
'st': 'adv',
'ob': "Relevance",
'sa': 'and',
'p': '1'
};


var app = initializeApp(
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxxxxxxxxxxirebaseapp.com',
databaseURL: 'xxxxxxxxxxxxxxxxxxxxxx.firebaseio.com',
projectId: 'xxxxxxxxxx7012',
storageBucket: 'storageBucket',
messagingSenderId: 'xxxxxxxxxx18'
);


var ref = firestore(app).collection("movies");

ref.get().then((snapshot){
snapshot.forEach((doc){
var imdbid = doc.data()['imdbid'];
print("imdbid: $imdbid");
});
});


var r =
GetNewMoviesImpl.instance(FetchMovieServiceImpl(), FirebaseRepository());



r.execute(queryParameters).then((r) {
print(r);
});
}

我可以从控制台Kotlin应用程序访问此数据库。我做错什么了吗?

最佳答案

浏览器外部没有allowInterop。此功能尤其适用于Dart-js-interop调用。您正在使用的firebase库可能也只能在浏览器中使用。服务器/控制台上仅支持Firebase管理员API。

https://github.com/fluttercommunity/firebase_flutter_sdk是纯Dart方法,应该在服务器上也可以使用,但我不知道其状态。

关于firebase - 未为类定义方法 'allowInterop'…尝试使用Firestore时Dart控制台应用程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54067013/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com