изображение, передающее контейнер - PullRequest
0 голосов
/ 15 апреля 2019

Я пытаюсь сделать это во флаттере:

need to do

И мой фактический результат:

need to do

Мой кодэто:

 new Container(
                  height: 150.0,
                  margin: const EdgeInsets.only(top: 16.0, bottom: 8.0),
                  child: new Stack(
                    children: <Widget>[
                      recantoCard,
                      recantoThumbnail,
                    ],
                  ),
                )
final recantoThumbnail = new Container(
  alignment: new FractionalOffset(0.0, 0.5),
  margin: const EdgeInsets.only(left: 5.0, top: 10),
  child: new Image(
    image: new AssetImage("assets/nossos_restaurantes.png"),
    height: 350.0,
  ),
);

final recantoCard = new Container(
  margin: const EdgeInsets.only(left: 0.0, right: 48.0),
  decoration: new BoxDecoration(
    color: Color(getColorHexFromStr("E5E6E8")),
    shape: BoxShape.rectangle,
  ),
  child: new Container(
    margin: const EdgeInsets.only(top: 10.0, left: 170.0),
    constraints: new BoxConstraints.expand(),
    child: new Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        new Text("text",
            style: TextStyle(
                color: Colors.black,
                fontFamily: 'Poppins',
                fontWeight: FontWeight.w600,
                fontSize: 20.0)),
        new Text("texto:",
            style: TextStyle(
                color: Colors.black,
                fontFamily: 'Poppins',
                fontWeight: FontWeight.w500,
                fontSize: 17.0)),
      ],
    ),
  ),
);

Изображение является файлом .png, и мне нужно переместить его в контейнер и стек, но изображение всегда остается в контейнере высотой 150.Как я могу преодолеть контейнер с изображением?

1 Ответ

1 голос
/ 15 апреля 2019

Чтобы ваше изображение выходило за пределы контейнера, вы должны использовать Matrix4.translationValues ​​(double x, double y, double z) class.

Используйте этот класс, когда вам нужно выполнить overpass transform: Matrix4.translationValues ​​(0.0, 60, 0.0) ,

Container(
            height: 150.0,
            color: Colors.red,
              child: Center(
                 child:Container(
                   height: 130.0,
                   width: 130.0,
                    transform: Matrix4.translationValues(0.0, 60, 0.0),

                   child: Image.asset('assets/image.jpg'),
                 )
              ),
          )

This image will the result of the above code

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...