Skip to main content

Command Palette

Search for a command to run...

RotatedBox Widget and Attributes

Published
2 min read
RotatedBox Widget  and Attributes
V

"Hello World, I'm Vinit Mepani, a coding virtuoso driven by passion, fueled by curiosity, and always poised to conquer challenges. Picture me as a digital explorer, navigating through the vast realms of code, forever in pursuit of innovation.

In the enchanting kingdom of algorithms and syntax, I wield my keyboard as a magical wand, casting spells of logic and crafting solutions to digital enigmas. With each line of code, I embark on an odyssey of learning, embracing the ever-evolving landscape of technology.

Eager to decode the secrets of the programming universe, I see challenges not as obstacles but as thrilling quests, opportunities to push boundaries and uncover new dimensions in the realm of possibilities.

In this symphony of zeros and ones, I am Vinit Mepani, a coder by passion, an adventurer in the digital wilderness, and a seeker of knowledge in the enchanting world of code. Join me on this quest, and let's create digital wonders together!"

The RotatedBox widget is a Flutter widget that allows you to rotate its child widget by a specified angle. This can be particularly useful when you need to display content in a rotated state without affecting the layout of the surrounding widgets.

Attributes of RotatedBox Widget:

1. child:

  • Type: Widget

  • Required: Yes

  • The child attribute is mandatory and represents the widget that you want to rotate. It could be any Flutter widget, such as a Container, Text, Image, or another complex widget.

2. quarterTurns:

  • Type: int

  • Default Value: 0

  • The quarterTurns attribute specifies the number of clockwise quarter turns to rotate the child. It is an integer value, and each quarter turn corresponds to a 90-degree rotation. For example, a value of 1 will rotate the child by 90 degrees, and a value of 2 will rotate it by 180 degrees.

Example of RotatedBox Widget:

Let's consider a simple example to illustrate the usage of the RotatedBox widget. In this example, we'll rotate a Container containing text by 45 degrees clockwise.

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('RotatedBox Example'),
        ),
        body: Center(
          child: RotatedBox(
            quarterTurns: 1,
            child: Container(
              width: 150,
              height: 80,
              color: Colors.blue,
              child: Center(
                child: Text(
                  'Rotated Text',
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

In this example:

  • The RotatedBox widget is used to wrap a Container containing the text 'Rotated Text'.

  • The quarterTurns attribute is set to 1, resulting in a 90-degree clockwise rotation.

  • The Container has a width, height, and background color for better visibility.

Learn Flutter

Part 1 of 50

Explore Flutter's magic in crafting cross-platform apps effortlessly. Join the adventure!

More from this blog

Vinit Mepani (Flutter Developer)

270 posts

"Vinit Mepani, passionate coder! Dive into my Dart and Flutter journey on the blog. Let's master these tech wonders together. Happy coding! 🚀"