Skip to content

TabBar with padding not functioning as expected #112776

@jwseph

Description

@jwseph

Expected result

When selecting a tab in a scrollable TabBar, if possible, the tab glides to the center of the TabBar.

Actual result

If the TabBar is scrollable and its padding parameter is specified, the TabBar does not take the padding into account when selecting a tab and glides to an off-centered position.

(tested in Android, not sure about iOS/Web)

GIF of the issue

20221002_185236

Steps to reproduce

  1. Select a tab in a TabBar with padding
Sample code
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  
  @override
  Widget build(BuildContext context) => MaterialApp(
    home: DefaultTabController(
      length: 12,
      child: Scaffold(
        appBar: AppBar(
          title: Text('App demo'),
          bottom: TabBar(
            padding: EdgeInsets.symmetric(horizontal: 24),
            isScrollable: true,
            tabs: [
              for (int i = 0; i < 12; i++) Tab(text: 'Tab ${i+1}'),
            ],
          ),
        ),
        body: TabBarView(
          children: [
            for (int i = 0; i < 12; i++) Container(),
          ]
        ),
      ),
    ),
  );
}
Logs
[√] Flutter (Channel stable, 3.0.4, on Microsoft Windows [Version 10.0.19043.2006], locale en-US)
    • Flutter version 3.0.4 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 85684f9300 (3 months ago), 2022-06-30 13:22:47 -0700
    • Engine revision 6ba2af10bb
    • Dart version 2.17.5
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Users\Jet_g\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.31624.102
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] VS Code, 64-bit edition (version 1.71.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.48.0

[√] Connected device (4 available)
    • SM A136U1 (mobile) • R5CT12A42CV • android-arm    • Android 12 (API 31)
    • Windows (desktop)  • windows     • windows-x64    • Microsoft Windows [Version 10.0.19043.2006]
    • Chrome (web)       • chrome      • web-javascript • Google Chrome 105.0.5195.127
    • Edge (web)         • edge        • web-javascript • Microsoft Edge 105.0.1343.42

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: 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