我如何在'Scaffold'和'StreamBuilder'之间添加图像和文本标题?

问题描述 投票:0回答:1

[我在这里尝试在'Scaffold'和'StreamBuilder'之间添加Image和AppBar。但是我什么时候 添加Image或appBar会出现redLine错误,这意味着'Scaffold'和'StreamBuilder'不会 支持AppBar和Image。

现在在“ StreamBuilder”的上方具有Image和AppBar应该怎么办

  class MyDetailPage extends StatefulWidget {
  @override
  _MyDetailPageState createState() => new  _MyDetailPageState();
}

class _MyDetailPageState extends State<MyDetailPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(

 // Want to add Image & appBar between the Scaffold & StreamBuilder .
  // How can I do this?

      body: StreamBuilder(
    stream:  Firestore.instance.collection('client').snapshots(),
    builder: (context,snapshot){
        return ListView.builder(
              itemCount: snapshot.data.documents.length,
            itemBuilder: (context,index){
                DocumentSnapshot client =snapshot.data.documents[index];
                return
                  SingleChildScrollView(
                  child:
              Container(
                    height: 300,
                    child: Card(
                      color: Colors.white,
                      shape: RoundedRectangleBorder(
                        side: BorderSide(color: Colors.purpleAccent,width: 2),
                        borderRadius: BorderRadius.circular(10),
                      ),
                      child: Padding(
                        padding: const EdgeInsets.all(16.0),
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                          SizedBox(width: 10),
                               Expanded(
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: <Widget>[
                                  Text('Name:- ${client['fname']}\n', style: new TextStyle(fontSize: 
                                 12.0,color: Colors.black),),
                                   Row(
                                    children: <Widget>[
                                      Expanded(
                                        child: Text('detail:- ${client['purpose']}\n', style: new 
                              TextStyle(fontSize: 12.0,),),
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                            )

                          ],
                        ),
                      ),
                    ),
                  )

                );
            },
        );
    },
    ),


    );
  }
}
flutter dart firebase-realtime-database google-cloud-firestore
1个回答
0
投票
home: Scaffold(
    appBar: AppBar(
      actions: <Widget>[
        // your widget
      ],
    ),
  ),

您可以像这样将appBar添加到Scaffold中,并且可以从AppBar class 了解更多关于Scaffold appBar的信息>

© www.soinside.com 2019 - 2024. All rights reserved.