Home > Mobile >  How to center the Text in the middle of the Container? Flutter
How to center the Text in the middle of the Container? Flutter

Time:12-07

i want to center my texts in the middle of my containers but they only center them in top middle of the containers. Here is my code:

import 'package:flutter/material.dart';

class Homepage extends StatefulWidget {
  const Homepage({Key? key}) : super(key: key);

  @override
  _HomepageState createState() => _HomepageState();
}

class _HomepageState extends State<Homepage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Homepage'),
          backgroundColor: Colors.green,
        ),
        body: SafeArea(
          child: Column(
            children: <Widget>[
              Container(
                margin: EdgeInsets.fromLTRB(75, 100, 75, 100),
                height: 100,
                width: 300,
                color: Colors.green,

                child: const Text('BLE & Data'),
              ),
              //const SizedBox(height: 10),
              Container(
                margin: EdgeInsets.fromLTRB(75, 25, 75, 100),
                height: 100,
                width: 300,
                color: Colors.green,
                child: const Text('Statistiken',
                  textAlign: TextAlign.center,),
              ),
              const SizedBox(height: 10),
                Container(
                  //padding: EdgeInsets.all(50),
                  margin: EdgeInsets.fromLTRB(75, 25, 75, 100),
                height: 100,
                width: 300,
                color: Colors.green,
                child: const Text('Personal Data',
                  textAlign: TextAlign.center,
                  ),
              ),
            ],
          ),
        ));
  }
}

And that´s my output: enter image description here

  • Related