Skip to content

Instantly share code, notes, and snippets.

@kmvignesh
Created August 30, 2020 14:53
Show Gist options
  • Select an option

  • Save kmvignesh/911e07205c8aa9adf7b324985559f63d to your computer and use it in GitHub Desktop.

Select an option

Save kmvignesh/911e07205c8aa9adf7b324985559f63d to your computer and use it in GitHub Desktop.
Source code of Stack tutorial.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Stack"),
),
body: Center(
child: Container(
width: 400,
height: 400,
color: Colors.yellow,
child: Stack(
alignment: Alignment.topLeft,
clipBehavior: Clip.hardEdge,
children: [
Container(
width: 150,
height: 150,
color: Colors.green,
),
Align(
alignment: Alignment(-0.5,-0.5),
child: Container(
width: 200,
height: 200,
color: Colors.red,
),
),
Positioned(
left: -10,
top: -200,
height: 300,
child: Container(
width: 200,
height: 200,
color: Colors.transparent,
),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment