Flutter:如何在容器内的ListView上方添加文本行

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

我在其中一个屏幕中有以下代码。我需要在ListView小部件上方添加一行文本。我试过在装有ListView的容器的上方和下方添加一个Column小部件,但似乎无法正确处理。

谁能告诉我我该怎么做?

干杯,

保罗

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      child: Scaffold(
        appBar: rmoAppBar(subText: 'My Jobs'),
        drawer: RmoMenu(),
        body: isLoading
            ? Center(child: CircularProgressIndicator())
            : Container(
                child: ListView.builder(
                  itemCount: jobs.sjRows.length,
                  itemBuilder: (BuildContext context, int index) {
                    return jobCard(jobs.sjRows, index);
                  },
                ),
              ),
      ),
      onWillPop: () => logoutAlert(context: context),
    );
  }
flutter flutter-layout
1个回答
1
投票
@override
Widget build(BuildContext context) {
  return WillPopScope(
    child: Scaffold(
      appBar: rmoAppBar(subText: 'My Jobs'),
      drawer: RmoMenu(),
      body: isLoading
          ? Center(child: CircularProgressIndicator())
          : Column(
        children: [
          Text('Your text goes here'), 
          Expanded(
            child: ListView.builder(
              itemCount: jobs.sjRows.length,
              itemBuilder: (BuildContext context, int index) {
                return jobCard(jobs.sjRows, index);
              },
            ),
          )
        ],
      ),
    ),
    onWillPop: () => logoutAlert(context: context),
  );
}
© www.soinside.com 2019 - 2024. All rights reserved.