Flutter Vertical Text Direction: An Example

Last updated on July 18, 2021 A Goodman Loading... Post a comment

In Flutter, you can set the orientation of the text characters in a line to vertical by wrapping a Text widget inside a RotatedBox widget, like this:

RotatedBox(
              quarterTurns: 1,
              child: Text(
                'Just Some Vertical Text',
                style: TextStyle(fontSize: 50),
              ),
            ),

A Complete Example

Screenshot:

The full code:

// main.dart
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        // Remove the debug banner
        debugShowCheckedModeBanner: false,
        title: 'Kindacode.com',
        theme: ThemeData(
          primarySwatch: Colors.amber,
        ),
        home: HomePage());
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Kindacode.com'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(30),
        child: Row(
          children: [
            RotatedBox(
              quarterTurns: 1,
              child: Text(
                'Just Some Vertical Text',
                style: TextStyle(fontSize: 50),
              ),
            ),
            SizedBox(
              width: 30,
            ),
            RotatedBox(
              quarterTurns: 3,
              child: Text(
                'Just Some Vertical Text',
                style: TextStyle(fontSize: 50),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Continue learning Flutter:

You can also check out our Flutter category page, or Dart category page for the latest tutorials and examples.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

You May Also Like