Flutter - 如何将 appBar 上的按钮对齐到左侧?

Flutter - How can I align the buttons on the appBar to the left?

Flutter 中 appBar 上的操作按钮默认对齐到右侧,我想将我的 FlatButton 对齐到左侧,紧挨着 title/logo。

有人可以指点一下吗?

下面是我的代码:

@override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.white,
          title: const Text('Logo'),
          elevation: 0.0,
           actions: <Widget>[

            FlatButton(
                onPressed: () {
                  _select(choices[0]);
                },
                child: Text(
                  'Portfolio',
                  style: TextStyle(
                      fontFamily: 'Futura',
                      fontSize: 12,
                      color: Color.fromRGBO(80, 86, 89, 100)),
                )),

干杯, 凯伦

在操作中添加像 Container 这样的默认小部件并将其包装在 Expanded 小部件中

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
            backgroundColor: Colors.white,
            title: const Text('Logo'),
            elevation: 0.0,
            actions: <Widget>[
              FlatButton(
                  onPressed: () {},
                  child: Text(
                    'Portfolio',
                    style: TextStyle(
                        fontFamily: 'Futura',
                        fontSize: 12,
                        color: Color.fromRGBO(80, 86, 89, 100)),
                  )),
              Expanded(
                child: Container(),
              ),
            ]),
      ),
    );
  }
import 'package:flutter/material.dart';

class TestPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Row(
          children: <Widget>[
            Text(
              'Actions Align Left',
            ),
            FlatButton(
              child: Text('FlatButton'),
            )
          ],
        )
      ),
    );
  }
}

我用 Row 作为标题,只是把 FlatButton 放在那里。

您还可以使用 AppBarleading 属性,在标题前放置一个小部件。如果您在那里需要多个小部件,可以将它们嵌套在 Row.