import 'package:flutter/material.dart';
void main() => runApp(new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text("对齐"),
),
body: new Stack(
children: [
Align(
//左上
alignment: new FractionalOffset(0.0, 0.0),
child: new Image.asset("images/1.jpeg", width: 120, height: 120),
),
Align(
//右上
alignment: FractionalOffset.topRight,
child: new Image.asset("images/1.jpeg", width: 120, height: 120),
),
Align(
//水平居中
alignment: new FractionalOffset(0.5, 0.5),
child: new Image.asset("images/1.jpeg", width: 120, height: 120),
),
Align(
//左下角
alignment:FractionalOffset.bottomLeft,
child: new Image.asset("images/1.jpeg", width: 120, height: 120),
),
Align(
//右下角
alignment:FractionalOffset.bottomRight,
child: new Image.asset("images/1.jpeg", width: 120, height: 120),
),
Align(
//左中
alignment:FractionalOffset.centerLeft,
child: new Image.asset("images/a.jpg", width: 120, height: 120),
),
Align(
//左中
alignment:FractionalOffset.centerRight,
child: new Image.asset("images/a.jpg", width: 120, height: 120),
),
Align(
//上中
alignment:FractionalOffset.topCenter,
child: new Image.asset("images/a.jpg", width: 120, height: 120),
),
Align(
//下中
alignment:FractionalOffset.bottomCenter,
child: new Image.asset("images/a.jpg", width: 120, height: 120),
),
],
),
),
));
参考:Flutter 技术入门与实战