美文网首页
27.Flutter的Stack组件的使用

27.Flutter的Stack组件的使用

作者: 凯司机 | 来源:发表于2020-06-10 15:58 被阅读0次

classMyHomeBodyextendsStatelessWidget{

  @override

  Widget build(BuildContext context) {

    return Stack(

      children: <Widget>[

        Container(

          color: Colors.purple,

          width: 300,

          height: 300,

        ),

        Positioned(

          left: 20,

          top: 20,

          child: Icon(Icons.favorite, size: 50, color: Colors.white)

        ),

        Positioned(

          bottom: 20,

          right: 20,

          child: Text("你好啊,KSJ", style: TextStyle(fontSize: 20, color: Colors.white)),

        )

      ],

    );

  }

}

⚠️:**注意:**Positioned组件只能在Stack中使用。

相关文章

网友评论

      本文标题:27.Flutter的Stack组件的使用

      本文链接:https://www.haomeiwen.com/subject/sfjptktx.html