Flutter 相对布局实现:Stack 加上Align
作者:互联网
import 'package:flutter/material.dart'; /// 使用 MediaQuery 进行全面屏适配 void main() { runApp(HomePage()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: HomePage(), ); } } class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { /// 获取当前的 padding 信息 return Container( width: 500, height: 45, color: Colors.yellow, child: Stack( children: <Widget>[ Align( alignment: Alignment(-0.9, 0), child: Icon( Icons.card_travel, size: 80, color: Colors.green, ), ), Align( alignment: Alignment(-0.5, -0.2), child: Icon( Icons.card_travel, size: 80, color: Colors.pink, ), ), Align( alignment: Alignment(-0.5, 0), child: Icon( Icons.card_travel, size: 80, color: Colors.black, ), ), ], ), ); } }
标签:Icons,color,Align,Flutter,Colors,child,80,Stack 来源: https://www.cnblogs.com/lenkevin/p/16492170.html