SizedBox Widget

 import "package:flutter/material.dart";


void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Hello",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: const FlutterApp(),
);
}
}

class FlutterApp extends StatefulWidget {
const FlutterApp({super.key});

@override
State<StatefulWidget> createState() {
return FlutterState();
}
}

class FlutterState extends State<FlutterApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: const Drawer(),
appBar: AppBar(
title: const Text(
"Flutter SizedBox",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: /*Center(
child: SizedBox(
width: 200,
height: 50,
child: ElevatedButton(
onPressed: (){

}, child: const Text("Clicked!!"),
),
),
),*/
/*Center(
child: SizedBox.expand( //Maximum height and width of the parent will adopt
child: ElevatedButton(
onPressed: (){

}, child: const Text("Clicked!")
),
),
),*/

/*ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 200,
minHeight: 40,
maxHeight: 80,
maxWidth: 400,
),
child: SizedBox.shrink( //Minimum height and width of the parent will adopt
child: ElevatedButton(
onPressed: (){

}, child: const Text("Clicked!")
),
),
),*/

Wrap(
direction: Axis.vertical,
children: [
SizedBox.square(
dimension: 100,
child: ElevatedButton(
onPressed: () {},
child: const Text("Clicked!"),
),
),
const SizedBox(
//width: 20,
height: 20,
),
SizedBox.square(
dimension: 100,
child: ElevatedButton(
onPressed: () {},
child: const Text("Clicked!"),
),
),
const SizedBox(
//width: 50,
height: 50,
),
SizedBox.square(
dimension: 100,
child: ElevatedButton(
onPressed: () {},
child: const Text("Clicked!"),
),
),
],
),
);
}
}

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