Home > Back-end >  how to align the AppBar title to right in flutter?
how to align the AppBar title to right in flutter?

Time:09-21

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          toolbarHeight: 50.0,          
          title: const Text(
            'This is the title !',
            style: TextStyle(color: Colors.black),
          ),
          backgroundColor: Colors.amber,
        ),
      ),
    ));

CodePudding user response:

Wrap your title in a Align and apply Alignment.centerRight to it

Scaffold(
      appBar: AppBar(
        title: Align(
          alignment: Alignment.centerRight,
          child: Text(
            "My title",
            
          ),
        ),

CodePudding user response:

  return Scaffold(
        appBar: AppBar(
        title: Align(
        alignment: Alignment.centerRight,
        child: Text(
        "title",

    ),),),
      body: getText("text"),
    );

enter image description here

CodePudding user response:

put the title in actions rather than the title or leading to add it to the left

  • Related