Notice: Undefined variable: user_id in /home/thetexvn/domains/thetexvn.com/public_html/blogs/follow.php on line 40
Learn Flutter Align Widget Secrets - Flutter Tutorial | by Zia | TEXVN

Conversation

Your input fuels progress! Share your tips or experiences on prioritizing mental wellness at work. Let's inspire change together!

Join the discussion and share your insights now!

Comments 0


advertisement

Learn Flutter Align Widget Secrets - Flutter Tutorial

Align Widget in Flutter

Align Widget

Align Widget as the name suggests, is utilized for moving the widget to one side or the other. Widgets can be aligned left, right, or in any other direction.

Properties of align widget

  • key: It is a unique key to control the widget.
  • alignment: Used for setting the type of alignment.
  • widthFactor: Used for setting the width for the align widget.
  • heightFactor: Used to set the height for the align widget.
  • child: defines the child of the Align widget.


When and How to Use the Align Widget?

The Align Widget is utilized to align its child widgets to the defined alignment. If a particular widget must be aligned to the bottom of the screen, the align widget can be utilized for that operation to be performed.

The use of Align Widget in Flutter:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Simple Align Example'),
        ),
      body: Align(
        alignment: Alignment.center,
        child: Container(
          width: 150,
          height: 150,
          color: Colors.teal,
          child: Align(
            alignment: Alignment.bottomRight,
            child: Text(
              'Hello, TEXVN!',
              style: TextStyle(color: Colors.white, fontSize: 20),
            ),
          )
        ),
      ),
      ),
    );
  }
}




Flutter Alignment Align Widget Align widget in Flutter Alignment in FLutter Alignment Widget Alignment Widget in Flutter

advertisement


Profile Image

Published by: 

1 Follower

Zia, founder and CEO of Texvn and Toolx, is a passionate entrepreneur and tech enthusiast. With a strong focus on empowering developers, he creates innovative tools and content, making coding and idea generation easier.