简体   繁体   中英

How to create parallelogram shape Container in Flutter?

I really don,t know how to create a parallelogram shape container in a flutter. I also found the flutter library for this but I can't use it because this is not supported by null safety. 在此处输入图像描述

You can use transform with skewX for this.

Container(
  width: 400,
  height: 100,
  transform: Matrix4.skewX(-.3),
  decoration: BoxDecoration(
    border: Border.all(
      color: Colors.black,
    ),
    color: Colors.amber,
  ),
),

For a shape like this you need to use CustomPainter for details on how to use it you can refer to this .

You can also use a website like flutter shape maker for the same thing but to make it easier you can draw your shape and it'll auto generate the code for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM