Paul Coshott
Paul Coshott

Reputation: 991

Flutter: How to add a text line above a ListView inside a Container

I have the following code in one of my screens. I need to add a line of text above the ListView widget. I've tried adding a Column widget above and below the Container that holds the ListView, but I can't seem to get it right.

Can anyone tell me how I do this?

Cheers,

Paul

  @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),
    );
  }

Upvotes: 0

Views: 1728

Answers (1)

CopsOnRoad
CopsOnRoad

Reputation: 267474

@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),
  );
}

Upvotes: 2

Related Questions