我正在尝试设置firebase函数,但运行firebase init后出错.
错误:HTTP错误:401,请求具有无效的身份验证凭据.预期的OAuth 2访问令牌,登录cookie或其他有效的身份验证凭据.请参阅https://developers.google.com/identity/sign-in/web/devconsole-project.
我在网络上使用 Firebase 插件并设法使用 Firestore 和身份验证。现在,我正在尝试启用 Firebase 存储,但是当我实例化存储时,我会出现此错误
tried to call a non-function, such as null: 'dart.global.firebase.storage
Run Code Online (Sandbox Code Playgroud)
对于 Firestore 和身份验证,我使用:
import 'package:firebase/firebase.dart' as fb;
import 'package:firebase/firestore.dart';
fb.Auth _firebaseAuth = fb.auth();
Firestore _firestore =fb.firestore();
Run Code Online (Sandbox Code Playgroud)
用于存储:
fb.Storage storage = fb.storage();
Run Code Online (Sandbox Code Playgroud) 我正在使用本地通知插件,一切正常,除了当我点击通知时。我想在用户点击通知时导航到特定屏幕
Future onSelectNotification(String payload) async {
//convert payload json to notification model object
try{
Map notificationModelMap = jsonDecode(payload);
NotificationModel model = NotificationModel.fromJson(notificationModelMap);
await Navigator.push(
context,// it`s null!
new MaterialPageRoute(
builder: (context) => CommitmentPage(model)));}
catch(e){print(e.toString());}
}
Run Code Online (Sandbox Code Playgroud)
但上下文始终为空并给我一个例外
NoSuchMethodError: The method 'ancestorStateOfType' was called on null
。
编辑
我尝试使用 navigatorKey 并将其传递给 @Günter Zöchbauer 建议的材料应用程序,但它给了我另一个例外
Navigator operation requested with a context that does not include a Navigator.
The context used to push or pop routes from the Navigator must be that of a …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从互联网加载图像,但我想显示一个占位符,直到加载完成。
如何确定占位符的大小以匹配图像的实际大小?
来自api的图像的宽度和高度分别为2000、3000。如何转换这些值?
我正在使用分页库和房间,使我的房间数据库成为我的应用程序的单层真相。当使用改造从服务器获取数据时,我将结果本地保存在db中,然后使用分页库从db中获取数据。我正在使用BoundaryCallback。
@Override
public void onZeroItemsLoaded() {
requestAndSaveData();
}
@Override
public void onItemAtEndLoaded(@NonNull Photo itemAtEnd) {
requestAndSaveData();
}
Run Code Online (Sandbox Code Playgroud)
private void requestAndSaveData() {
if (isRequestInProgress) return;
isRequestInProgress = true;
apiInterface.getPhotos(lastRequestPage, NETWORK_PAGE_SIZE).enqueue(new Callback<PhotoList>() {
@Override
public void onResponse(Call<PhotoList> call, Response<PhotoList> response) {
if (response.isSuccessful()) {
cache.insertPhotos(response.body().getHits()); //todo only save 20 - 40 items
lastRequestPage++;
isRequestInProgress = false;
Log.i("deb", "number from boundary: " + response.body().getHits().size());
}
}
Run Code Online (Sandbox Code Playgroud)
当数据库中没有项目或用户滚动到最后一个项目时,我调用requestAndSaveData()
从服务器获取数据并将其保存到数据库中的方法。
我的问题是,从服务器加载下一页并将其保存到数据库时,如何在列表底部显示进度条,这可能需要很长时间?
我正在尝试实现这种效果,但无法在圆圈内制作白色圆形笔画。在我的实现中,白色笔画出现在圆圈之外
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="10dip" />
<stroke
android:width="5dip"
android:color="#ffffff" />
<solid android:color="#f50000" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
预期输出:-
如何检测用户何时垂直向上或向下滑动?
我一直在使用swipedetector包,但现在,它给了我例外
The getter 'globalPosition' was called on null.
Run Code Online (Sandbox Code Playgroud) 如何在 Flutter 中添加带有固定 tabBar 的构建折叠应用栏,就像在这个 GIF 中一样
调用setData时如何获取新创建的文档id
Future<void> createCommitment() async {
await widget._firestore
.collection('skills')
.document(widget.skillID)
.collection("commitment")
.document()
.setData({
'bite_id': widget.biteId,
'start_date': widget.startDate,
'frequnecy': 3
});
}
Run Code Online (Sandbox Code Playgroud)
当前实现返回 void
我想实现像这张照片。为简化起见,我创建了一个包含两个容器的堆栈。我想使用Align小部件将小容器的底部居中,但无法正常工作!它始终保持在顶部
Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: 170,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0))),
// child: Image.network(tutorImage),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: 60,
height: 60,
color: Colors.black,
),
)
],
),
Run Code Online (Sandbox Code Playgroud)
UserCollection/{id}/PlayerCollection/{id}
Run Code Online (Sandbox Code Playgroud)
在最后一个文档中,有多个字段
active: true or false
dateInMillies : 123456789
return _firestore
.collection('UserCollection')
.document(userID)
.collection("PlayerCollection")
.orderBy('dateInMillis', descending: true)
.where('active', isEqualTo: true)
.snapshots();
Run Code Online (Sandbox Code Playgroud)
此代码块通过异常:
failed: Status{code=FAILED_PRECONDITION, description=The query requires an index. You can create it here: link to fix it
Run Code Online (Sandbox Code Playgroud)
但是链接已损坏,所以我必须手动完成!
所以,我去了索引选项卡,并创建了一个新的复合索引
collectionID : PlayerCollection
Fields Indexed: dateInMillis : Descending , active : Ascending
Run Code Online (Sandbox Code Playgroud)
但也没有用!
flutter ×8
dart ×4
firebase ×4
android ×2
android-xml ×1
firebase-cli ×1
flutter-web ×1
retrofit2 ×1