Skip to content

Instantly share code, notes, and snippets.

@IshanFx
Created February 10, 2019 13:41
Show Gist options
  • Save IshanFx/5e8008da55fc8960984a8a5c76f25ea0 to your computer and use it in GitHub Desktop.
Save IshanFx/5e8008da55fc8960984a8a5c76f25ea0 to your computer and use it in GitHub Desktop.
Flutter Stack of cards
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Card Stack'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
top: 10,
child: Card(
elevation: 4,
color: Color.fromARGB(255, 0, 0, 255),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
child: Container(
width: 200,
height: 300,
),
),
),
Positioned(
top: 20,
child: Card(
elevation: 8,
color: Color.fromARGB(255, 0, 255, 0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
child: Container(
width: 220,
height: 300,
),
),
),
Positioned(
top: 30,
child: Card(
elevation: 12,
color: Color.fromARGB(255, 200, 0, 0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
child: Container(
width: 240,
height: 300,
),
),
)
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment