oth man
oth man

Reputation: 303

stack in listview flutter infinite height

i want to put a card between an image and the rest of the page

so i used stack in listview builder but it doesn't give the expected result

what i want

enter image description here

what i get => https://i.sstatic.net/Oxy41.jpg

ListView.builder(
      itemCount: 1,
      itemBuilder: (context, i) {
        return Stack(
          children: <Widget>[
            first(_listviewurl, _listViewData[0], _listviewwe9t),
            Container(
              padding: EdgeInsets.all(40),
              child: Text(
                "News",
                style: TextStyle(
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                    fontSize: 32),
              ),
            ),
        Positioned(
        width: MediaQuery.of(context).size.width / 2.5,
        height: MediaQuery.of(context).size.height / 5,
        left: MediaQuery.of(context).size.width / 9,
        top: MediaQuery.of(context).size.height / 1.9,
        child: Card(
          semanticContainer: true,
          clipBehavior: Clip.antiAliasWithSaveLayer,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(20),
          ),
          child: Image.asset(
            "images/img1.jpg",
            fit: BoxFit.fill,
          ),
        ),
      ),
          ],
        );
      },
    ),

Upvotes: 2

Views: 947

Answers (1)

hoangquyy
hoangquyy

Reputation: 2063

Because your card is in your listview and your listview's height is the same with your first Widget, you can add Container as parent widget of your Stack widget and set height for it:

Container(
  child: Stack(...)
)

Upvotes: 1

Related Questions