Stack Widget

 /// Stack : To execute Overlapping structure, Stack is used,A Stack’s content can’t scroll


import "package:flutter/material.dart";

void main() {
runApp(MyApp(),);
}
class MyApp extends StatelessWidget {
MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Stack in Flutter",
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: StackDemo(),
);
}
}
class StackDemo extends StatelessWidget {
StackDemo({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Stack"),
),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 700,
height: 700,
child: Stack(
children: [
Container(
width: 200,
height: 200,
color: Colors.grey,
child: Text("1", style: TextStyle(color: Colors.white, fontSize: 40,),),
),
Positioned(
top: 50,
left: 50,
child: Container(
width: 200,
height: 200,
color: Colors.lightGreenAccent,
child: Text("2", style: TextStyle(fontSize: 40, color: Colors.black,),),
),
),
Positioned(
top: 100,
left: 100,
child: Container(
width: 200,
height: 200,
color: Colors.red,
child: Text("3", style: TextStyle(fontSize: 40, color: Colors.white,),),
),
),
Positioned(
top: 150,
left: 150,
child: Container(
width: 200,
height: 200,
color: Colors.deepPurple,
child: Text("4", style: TextStyle(fontSize: 40, color: Colors.white,),),
),
),
Positioned(
top: 200,
left: 200,
child: Stack(
children: [
Container(
width: 200,
height: 200,
color: Colors.limeAccent,
child: Text("5", style: TextStyle(fontSize: 40, color: Colors.black,),),
),
Container(
width: 130,
height: 130,
child: Image.asset("assets/images/geeksforgeeks.png"),
),
Positioned(
top: 110,
child: Text("Geeksforgeeks",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold,
decoration: TextDecoration.underline, fontStyle: FontStyle.italic, color: Colors.red,),),
),
],
),
),
Positioned(
top: 360,
left: 150,
child: Container(
width: 200,
height: 200,
color: Colors.purple,
child: Text("6", style: TextStyle(fontSize: 40, color: Colors.white,),),
),
),
Positioned(
top: 410,
left: 100,
child: Container(
width: 200,
height: 200,
color: Colors.teal,
child: Text("7", style: TextStyle(fontSize: 40, color: Colors.white,),),
),
),
Positioned(
top: 460,
left: 50,
child: Container(
width: 200,
height: 200,
color: Colors.brown,
child: Text("8", style: TextStyle(fontSize: 40, color: Colors.white,),),
),
),
Positioned(
top: 500,
child: Container(
width: 200,
height: 200,
color: Colors.cyan,
child: Text("9", style: TextStyle(fontSize: 40, color: Colors.black,),),
),
),
],
),
),
/*Row(
children: [
Image.asset("assets/images/hand_logo.jpg"),
],
),*/
Image.asset("assets/images/geeksforgeeks.png"),
Stack(
children: [
Image.asset("assets/images/natural.jpg"),
Positioned(
left: 20,
top: 50,
child: Text("Natural Scene",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25, fontStyle: FontStyle.italic,
color: Colors.deepPurple, decoration: TextDecoration.underline,),),
),
//Image.asset("assets/images/hand_logo.jpg"),
],
),
],
),
),

);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter