Позиционированный виджет в столбце приводит к переполнению карты - PullRequest
0 голосов
/ 14 марта 2019

В настоящее время я изучаю флаттер и столкнулся с проблемой, когда карта не находится в пределах границ столбца, но не вызывает переполнения.Моя цель - разместить карту внизу, а текст над ней.

Вот мой код:



  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
          children: <Widget>[
            Stack(
              children: <Widget>[
                Container(
                    height: MediaQuery.of(context).size.height,
                    child:
                        Image.asset("assets/testimage.jpg", fit: BoxFit.cover)),
                Positioned(
                  bottom: 10.0,
                  child: Card(
                    shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(15.0)),
                    child: Text(
                      "A description would be going here, this is just placeholder text.",
                      style: TextStyle(fontSize: 30),
                    ),
                  ),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }
}

и пример изображения проблемы и желаемого результата

Задача

Желаемый результат

1 Ответ

0 голосов
/ 14 марта 2019

Вам необходимо определить - right: 1.0, left: 1.0, также вместе с основанием в Positioned. виджет.

   @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Stack(
            children: <Widget>[
              Container(
                  height: MediaQuery.of(context).size.height,
                  child: Image.network("https://placeimg.com/640/480/any",
                      fit: BoxFit.cover)),
              Positioned(
                bottom: 1.0,
                right: 1.0,
                left: 1.0,
                child: Card(
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(15.0)),
                  child: Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(
                      "A description would be going here, this is just placeholder text.",
                      style: TextStyle(fontSize: 30),
                    ),
                  ),
                ),
              )
            ],
          ),
        ],
      ),
    );
  }

Выход:

enter image description here

...