CODE FOR THE DIFFERENT TYPES OF SINGLE CHILD LAYOUT WIDGETS AS DISCUSSED IN THE VIDEO
ALIGN
Align(
alignment: Alignment.centerRight,
child: Image.asset(
"assets/images/bike.jpg",
width: 100,
height: 100,
fit: BoxFit.fill,
),
),
CENTER
Center(
child: Image.asset(
"assets/images/bike.jpg",
width: 100,
height: 100,
fit: BoxFit.fill,
),
),
CONTAINER
Container(
width: 200,
height: 300,
padding: EdgeInsets.all(20),
color: Colors.red,
child: Image.asset(
"assets/images/bike.jpg",
fit: BoxFit.cover,
),
),
CONTAINER 2
Container(
width: 200,
height: 200,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/bike.jpg"),
fit: BoxFit.cover,
),
shape: BoxShape.circle,
),
),
CONTAINER 3
Center(
child: Container(
width: 200,
height: 200,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/bike.jpg"),
fit: BoxFit.cover,
),
shape: BoxShape.circle,
),
child: const Align(
alignment: Alignment.center,
child: Text(
"My Bike",
style: TextStyle(
color: Colors.blue,
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
SIZEDBOX
SizedBox(
height: 300.0,
width: 300.0,
child: Image.asset(
"assets/images/bike.jpg",
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
TRANSFORM
Transform(
transform: Matrix4.rotationZ(1),
child: Image.asset(
"assets/images/bike.jpg",
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
EXPANDED
Column(
children: [
Expanded(
child: Image.asset(
"assets/images/bike.jpg",
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
const SizedBox(
height: 10.0,
),
Expanded(
flex: 2,
child: Image.asset(
"assets/images/bike.jpg",
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
const SizedBox(
height: 10.0,
),
Expanded(
child: Image.asset(
"assets/images/bike.jpg",
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
],
),
No comments:
Post a Comment