This is full code:
class Application extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
body: new Container(
color: Color(0xff258DED),
height: 400.0,
alignment: Alignment.center,
child: new Container(
height: 200.0,
width: 200.0,
decoration: new BoxDecoration(
image: DecorationImage(
image: new AssetImage('assets/logo.png'),
fit: BoxFit.fill
),
shape: BoxShape.circle
),
),
child: new Container(
child: new Text('Welcome to Prime Message',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Aleo',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.bold,
fontSize: 25.0,
color: Colors.white
),
),
),
),
),
);
}
}
I tried to add a Container
on top and then added two children inside it. First child works fine, but second child giving me error like "the argument for the named parameter 'child' was already specified".
Column is a layout widget in flutter which aligns its children vertically. It can have multiple child widgets.
child. The child contained by the container. If null, and if the constraints are unbounded or also null, the container will expand to fill all available space in its parent, unless the parent provides unbounded constraints, in which case the container will attempt to be as small as possible.
In Flutter, to vertically center a child widget inside a Container, you can wrap the child widget with Column and add mainAxisAlignment: MainAxisAlignment. center to it.
You have to use mutichild widget like Column , Row , Stack.... It deepends on how you want to lay your widgets If you try to put more than one child in a container, you want to look as Row () or Column () class for linear ones. Stack () is used if you want to have floating children on top of each other.
You can connect multiple containers using user-defined networks and shared volumes. The container’s main process is responsible for managing all processes that it starts. In some cases, the main process isn’t well-designed, and doesn’t handle “reaping” (stopping) child processes gracefully when the container exits.
A container is a sandbox for an application. Containers are a modern way to run apps on your laptop, package your own apps, and even run apps in data centers. In short, they’re a super flexible way to share and run applications.
A container is usually created from an image. You can think of an image like a template or blueprint for creating containers. You can create hundreds (or millions) of containers from the same image. Images can be stored on your local machine, and you can share them with others. Most applications need libraries and system utilities to run.
If you try to put more than one child in a container, you want to look as Row()
or Column()
class for linear ones. Stack()
is used if you want to have floating children on top of each other.
Eg:
class Application extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
body: new Container(
color: Color(0xff258DED),
height: 400.0,
alignment: Alignment.center,
child: new Column(
children: [
new Container(
height: 200.0,
width: 200.0,
decoration: new BoxDecoration(
image: DecorationImage(
image: new AssetImage('assets/logo.png'),
fit: BoxFit.fill
),
shape: BoxShape.circle
),
),
new Container(
child: new Text('Welcome to Prime Message',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Aleo',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.bold,
fontSize: 25.0,
color: Colors.white
),
),
),
],
),
),
),
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With