Last active
January 21, 2021 14:35
-
-
Save felipecastrosales/8ebe6ad1d24641d59cdabfebd3919f7a to your computer and use it in GitHub Desktop.
Align Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(AlignExample()); | |
class AlignExample extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('Align - Example'), | |
centerTitle: true, | |
), | |
body: AlignWidgetDemo(), | |
), | |
); | |
} | |
} | |
class AlignWidgetDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
alignment: Alignment.center, | |
color: Colors.black, | |
child: Stack( | |
children: [ | |
Align( | |
alignment: Alignment(-0.75, -0.75), | |
child: MyImage(), | |
), | |
Align( | |
alignment: Alignment(0, 0), | |
child: MyImage(), | |
), | |
Align( | |
alignment: Alignment(0.75, 0.75), | |
child: MyImage(), | |
), | |
], | |
), | |
); | |
} | |
} | |
class MyImage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return FlutterLogo( | |
size: MediaQuery.of(context).size.height * .25, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment