下载URL Firebase存储颤振

下载URL Firebase存储颤振,firebase,flutter,firebase-storage,Firebase,Flutter,Firebase Storage,嘿,有人知道如何在这个:Image.network(url)中获取url变量吗 功能?但当我这样做时,它的下划线是红色的。当此url位于Image.network函数中时,即使有人重新启动应用程序,也会显示此图片。如果有人知道如何处理此问题,请在评论中告诉我 Future uploadPic(BuildContext context)async{ String fileName=basename(_image.path); StorageReference firebaseSto

嘿,有人知道如何在这个:Image.network(url)中获取url变量吗 功能?但当我这样做时,它的下划线是红色的。当此url位于Image.network函数中时,即使有人重新启动应用程序,也会显示此图片。如果有人知道如何处理此问题,请在评论中告诉我

Future uploadPic(BuildContext context)async{
    String fileName=basename(_image.path);
    StorageReference firebaseStorageRef=FirebaseStorage.instance.ref().child(fileName);
    StorageUploadTask uploadTask=firebaseStorageRef.putFile(_image);
    StorageTaskSnapshot taskSnapshot= await uploadTask.onComplete;
    var downUrl = await (await uploadTask.onComplete).ref.getDownloadURL();
    var url = downUrl.toString();

    setState(() {
      print('Profile Picture uploaded');
      Scaffold.of(context).showSnackBar(SnackBar(content: Text('Profile Picture Uploaded')));
    });
   }


  @override
  Widget build(BuildContext context) {

    Future<DocumentSnapshot> getUserInfo()async{
      var firebaseUser = await FirebaseAuth.instance.currentUser;
      return await Firestore.instance.collection("SerX").doc(firebaseUser.uid).get();
    }


    final _kTabPages = <Widget>[

      Center(child: Icon(Icons.new_releases, size: 64.0, color: Colors.white)),

      Center(child: Icon(Icons.local_grocery_store, size: 64.0, color: Colors.white)),

      Center(child: Icon(Icons.chat, size: 64.0, color: Colors.white)),


      ListView(
        children: <Widget> [
          Center(
            child: FutureBuilder(
              future: getUserInfo(),
              builder: (context, AsyncSnapshot<DocumentSnapshot> snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  return ListView.builder(
                      shrinkWrap: true,
                      itemCount: 1,
                      itemBuilder: (BuildContext context, int index) {
                        return ListTile(
                          subtitle: Text(snapshot.data.data()["Email"], style: TextStyle(
                            color: Colors.white,
                            fontFamily: 'Orbitron',
                            fontSize: 15.0,
                            fontWeight: FontWeight.bold,),textAlign: TextAlign.right,
                          ),
                          title: Text(snapshot.data.data()["Username"], style: TextStyle(
                              color: Colors.white,
                              fontFamily: 'Orbitron',
                              fontSize: 35.0,
                              fontWeight: FontWeight.bold),textAlign: TextAlign.right,),
                        );});
                } else if (snapshot.connectionState == ConnectionState.none) {
                  return Text("No data");}
                return Center(
                  child: SpinKitFadingCircle(color: Colors.white, size: 20.0),heightFactor: 29,
                );
              },
            ),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children:<Widget> [
              Container(
                padding:  EdgeInsets.only(left: 20),
                child: CircleAvatar(
                  radius: 50.0,
                  backgroundColor: Colors.white,
                  child: ClipOval(
                    child: SizedBox(
                      width: 95.0,
                      height: 95.0,
                      child:(_image!=null)?Image.file(_image,fit:BoxFit.fill)
                          :Image.network(".....", fit: BoxFit.fill,),
                    ),
                  ),
                ),
              ),
Future uploadPic(BuildContext上下文)异步{
字符串fileName=basename(_image.path);
StorageReference firebaseStorageRef=FirebaseStorage.instance.ref().child(文件名);
StorageUploadTask uploadTask=firebaseStorageRef.putFile(_image);
StorageTaskSnapshot taskSnapshot=等待上载Task.onComplete;
var downloadURL=await(await uploadTask.onComplete).ref.getDownloadURL();
var url=downUrl.toString();
设置状态(){
打印(“上传个人资料图片”);
Scaffold.of(context.showSnackBar(SnackBar(内容:Text('Profile Picture Uploaded')));
});
}
@凌驾
小部件构建(构建上下文){
未来的getUserInfo()异步{
var firebaseUser=等待FirebaseAuth.instance.currentUser;
返回wait wait Firestore.instance.collection(“SerX”).doc(firebaseUser.uid.get();
}
最终kTabPages=[
中心(子项:图标(Icons.new_发行版,尺寸:64.0,颜色:Colors.white)),
中心(子项:图标(Icons.local_杂货店,尺寸:64.0,颜色:Colors.white)),
中心(子项:图标(Icons.chat,大小:64.0,颜色:Colors.white)),
列表视图(
儿童:[
居中(
孩子:未来建设者(
future:getUserInfo(),
生成器:(上下文,异步快照){
if(snapshot.connectionState==connectionState.done){
返回ListView.builder(
收缩膜:对,
物品计数:1,
itemBuilder:(构建上下文,int索引){
返回列表块(
字幕:文本(snapshot.data.data()[“Email”],样式:TextStyle(
颜色:颜色,白色,
Fontron家族:“轨道飞行器”,
字体大小:15.0,
fontWeight:fontWeight.bold,),textAlign:textAlign.right,
),
标题:文本(snapshot.data.data()[“Username”],样式:TextStyle(
颜色:颜色,白色,
Fontron家族:“轨道飞行器”,
字体大小:35.0,
fontWeight:fontWeight.bold),textAlign:textAlign.right,),
);});
}else if(snapshot.connectionState==connectionState.none){
返回文本(“无数据”);}
返回中心(
子项:SpinKitFadingCircle(颜色:Colors.white,大小:20.0),高度因子:29,
);
},
),
),
划船(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
容器(
填充:仅限边缘设置(左:20),
孩子:圆环星(
半径:50.0,
背景颜色:Colors.white,
孩子:斜坡(
孩子:大小盒子(
宽度:95.0,
身高:95.0,
子项:(\u image!=null)?image.file(\u image,fit:BoxFit.fill)
:Image.network(“…”,fit:BoxFit.fill,),
),
),
),
),

代码似乎很好,Image.network(String src)应该能够接受字符串源代码。我已经尝试使用代码片段(Image upload和Image.network)复制此行为,但我没有遇到此问题。您可以运行
flatter-doctor
来检查是否有任何有用的警告。我在Android Studio 4.0上运行,使用了flatter 1.17.5和Dart 2.8.4 Firebase插件:Firebase_核心:^0.5.0 Firebase_存储:^4.0.0