Skip to content

SliverAppBar.medium & SliverAppBar.large title spacing doesn't account for automaticallyImplyLeading  #121511

@TahaTesser

Description

@TahaTesser

Reported in #120603 (comment)

code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(useMaterial3: true),
      home: const SliverAppBarExample(),
    );
  }
}

class SliverAppBarExample extends StatelessWidget {
  const SliverAppBarExample({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('SliverAppBar Sample'),
      ),
      body: Center(
        child: FilledButton(
          child: const Text('Go to SecondPage page'),
          onPressed: () {
            Navigator.of(context).push<void>(
              MaterialPageRoute<void>(
                builder: (BuildContext context) => const SecondPage(),
              ),
            );
          },
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  const SecondPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: <Widget>[
          // SliverAppBar(
          //   title: const Text('Sliver App Bar'),
          //   centerTitle: false,
          //   actions: <Widget>[
          //     IconButton(icon: const Icon(Icons.favorite), onPressed: () {}),
          //     IconButton(icon: const Icon(Icons.favorite), onPressed: () {}),
          //   ],
          // ),
          SliverAppBar.medium(
            title: const Text('Medium App Bar'),
            centerTitle: false,
            actions: <Widget>[
              IconButton(icon: const Icon(Icons.favorite), onPressed: () {}),
              IconButton(icon: const Icon(Icons.favorite), onPressed: () {}),
            ],
          ),
          const SliverFillRemaining(
            child: Center(
              child: Text(
                'Scroll down to collapse the app bar',
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Preview

Screenshot 2023-02-27 at 10 16 34

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions