Skip to content

Instantly share code, notes, and snippets.

Created June 2, 2022 01:46
What would you like to do?
Example of using Stack in Flutter
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch:,
home: const MyHomePage(),
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Flutter Demo Home Page')),
body: Center(
child: Stack(
alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none,
children: [
child: const Padding(
padding: EdgeInsets.fromLTRB(32, 56, 32, 32),
child: Text('Successful', style: TextStyle(fontSize: 32)),
top: -40,
child: Container(
child: const Icon(Icons.gpp_good, color:, size: 48),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color:, width: 4),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment