I'm new at flutter. I coded an example from youtube. At the home screen I have a text at the top:
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment(0, -0.5),
child: Text(
gameHasStarted ? '' : 'My App',
style: TextStyle(color: Colors.white, fontSize: 25),
),
);
}
}
Now I want to show another text at the bottom. Or on a another position. How to do that? I tried it with Row and Column but, then the two texts are depended from each other.
Thanks
CodePudding user response:
You need to wrap this part with Stack and set your Text where you want
Stack(
children: const [
Positioned(
top: 10,
left: 50,
child: Text("Hello"),
),
Positioned(
bottom: 50,
right: 110,
child: Text("Hello"),
),
],
)
or also use with align in stack
Stack(
children: const [
Align(
alignment: Alignment.topLeft,
child: Text("Hello3"),
),
Align(
alignment: Alignment.bottomRight,
child: Text("Hello4"),
)
],
)
CodePudding user response:
Maybe after wrapping both text with column ,
give mainAxisAlignment.spaceBetween .
Let me know if this solves your problem.
Only if you could provide a preview of screen, I could provide more help.
CodePudding user response:
The easiest solution would be using the column and setting its properties
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children:[
Text('My App'),
Text('My Text'),
],
),
