Skip to content

Conversation

@bernaferrari
Copy link
Contributor

@bernaferrari bernaferrari commented Jun 19, 2022

Fix #40802.

This is a breaking change, but a small one. I fixed the additional padding in AppBar by adding a missing variable in NavigationBar. Ideally both centerTitle values would lead to the same AppBar position. Included a test for both. And modified two existing tests (tests with random values).

image

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    debugPaintSizeEnabled = true;
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        useMaterial3: true,
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            AppBar(
              actions: <Widget>[
                IconButton(
                  tooltip: "favorite",
                  icon: const Icon(Icons.star),
                  onPressed: () {},
                ),
                IconButton(
                  tooltip: "copy color",
                  icon: const Icon(Icons.star),
                  onPressed: () {},
                ),
              ],
              title: Container(
                color: Colors.orange,
                child: const SizedBox(
                    width: double.infinity, child: Text("center: true")),
              ),
              centerTitle: true,
            ),
            AppBar(
              actions: <Widget>[
                IconButton(
                  tooltip: "favorite",
                  icon: const Icon(Icons.star),
                  onPressed: () {},
                ),
                IconButton(
                  tooltip: "copy color",
                  icon: const Icon(Icons.star),
                  onPressed: () {},
                ),
              ],
              title: Container(
                color: Colors.lightGreen,
                child: const SizedBox(
                    width: double.infinity, child: Text("center: false")),
              ),
              centerTitle: false,
            ),
          ],
        ),
      ),
    );
  }
}

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jun 19, 2022
@HansMuller HansMuller requested a review from QuncCccccc July 1, 2022 21:46
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSLGTM

@Hixie Hixie added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 17, 2022
@auto-submit auto-submit bot merged commit 0de1ca2 into flutter:master Aug 17, 2022
@bernaferrari bernaferrari deleted the AppBar branch August 17, 2022 20:13
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AppBar Bug with centerTitle:true with multiple actions

3 participants