Material SizedBox Widget Tutorial
A box with a specified size.
Material SizedBox Widget useful inputs
-
height: height of the widget, it’s take double value
-
width: width of the widget, it’s take double value
-
child: The widget below this widget in the tree.
Material SizedBox Widget example
SizedBox(
width: 300,
height: 300,
child: Helper.getText(),
)
Full codes example
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => (runApp(BoxExample()));
class Helper {
static getText() {
return Center(
child: Text(
"Box",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 60,
color: Colors.yellow,
),
),
);
}
}
class BoxExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Box Example"),
),
body: Row(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.red,
),
child: SizedBox(
width: 300,
height: 300,
child: Helper.getText(),
),
),
],
),
),
);
}
}