title: Flutter: How to center text with dynamic length?
body: <p>Hello I have created a custom appbar where the title of appbar will come from API which can any of the length so How can I center it.</p>
  <p>code of custom appbar,</p>
  <pre><code>class CustomAppBar extends PreferredSize {
    final String title;
    final double height;
    CustomAppBar({
      @required this.title,
      this.height = kToolbarHeight,
    });
    @override
    Size get preferredSize =&gt; Size.fromHeight(height);
  
    @override
    Widget build(BuildContext context) {
      final headline6 = Theme.of(context).textTheme.headline6;
      return Container(
        width: double.infinity,
        height: 99,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: [
              AppColors.veryDarkBlue,
              AppColors.blueWhale,
            ],
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            stops: [
              0.3,0.8
            ],
          ),
        ),
        padding: EdgeInsets.only(
          top: 27,
          left: 19,
        ),
        child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  InkWell(
                    child: Icon(
                      Icons.arrow_back_ios_rounded,
                      color: Colors.white,
                      size: 20.sdpHeight,
                    ),
                    onTap: () =&gt; Navigator.pop(context),
                  ),
                  Expanded(
                    child: Center(
                      child: Text(
                        title,                  //&lt;--- I want to align this
                        style: headline6.copyWith(
                          color: Colors.white,
                          fontSize: 16,
                        ),
                      ),
                    ),
                  ),
                ],
           )
      );
    }
  }
  
  </code></pre>
  <p>how it looks,</p>
  <p><a href="https://i.stack.imgur.com/gUwby.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gUwby.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/EIN1D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EIN1D.png" alt="enter image description here" /></a></p>
  <p>in second screen shot it has little more gap on left then it should be so How I can fix it?</p>