Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Last active January 21, 2021 14:35
Show Gist options
  • Save felipecastrosales/8ebe6ad1d24641d59cdabfebd3919f7a to your computer and use it in GitHub Desktop.
Save felipecastrosales/8ebe6ad1d24641d59cdabfebd3919f7a to your computer and use it in GitHub Desktop.
Align Example
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