Stack and Positioned.
Stack and Positioned.
stack widget is nothing but the a display screen on some other display screen.
we have to make
process same up to the creation of the body
then after creation of the body the process will change.
body: Container(
color: Colors.blue,
child: Center(
child: Stack(
children: [
Container(height: 250,width: 300,color: Colors.green,)
child: Stack(
children: [Positioned(
bottom:10,child:
Container(height: 250,width: 300,color: Colors.green,),),
Center(
child: Container(height: 150,width:150,color: Colors.red,)
)
child: Stack(
children: [Positioned(
bottom:10,
left:10,
right:10,
child:
Container(height: 250,width: 300,color: Colors.green,),),
Center(
child: Container(height: 150,width:150,color: Colors.red,)
)
body:Stack(
children: [
Positioned
(
bottom: 10,child: Container(child: Image.asset('assets/abc.png'),
))
here we used the image in the place of color block as before and now we are used
the images in the place of the
colors
import 'package:flutter/material.dart';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// backgroundColor: Colors.black,
title: Text('Stack'),
),
body: Stack(
children: [
Positioned(
child: Container(
height: 300,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Colors.red,
image: DecorationImage(
image: AssetImage('assets/download.jpg'),
fit: BoxFit.cover)),
),
),
Positioned(
left: 20,
top: 20,
child: Container(height: 50, width: 50, color: Colors.yellow),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(height: 50, width: 50, color: Colors.yellow),
)
],
));
}
}