Skip to content

TabBar indicatorWeight is not ignored as documented  #171951

Closed

Description

@qeepcologne

Steps to reproduce

  1. define tabBarTheme with indicator
  2. use TabBar like

Expected results

documentation in tabs.dart says:

  /// If [indicator] is not null or provided from [TabBarTheme],
  /// then [indicatorWeight] and [indicatorColor] are ignored.

Actual results

IndicatorWeight is not ignored, 2 pixels are inserted.
Because it is not possible to set value to zero, i used indicatorWeight: 0.0000001 in TabBar as workaround

Code sample

  tabBarTheme: Theme.of(context).tabBarTheme.copyWith(
    unselectedLabelColor: neutral800,
    unselectedLabelStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
    labelColor: neutral800,
    labelStyle: TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
    indicatorColor: red500,
    dividerColor: Colors.transparent,
    indicator: BoxDecoration(
      color: neutral100,
      borderRadius: BorderRadius.circular(smallBorderRadius),
      border: BoxBorder.fromBorderSide(BorderSide(color: neutral800)),
    ),
    indicatorSize: TabBarIndicatorSize.tab,
  ),
  TabBar(
    padding: EdgeInsets.symmetric(horizontal: mediumPadding / 2),
    indicatorPadding: EdgeInsetsGeometry.symmetric(vertical: mediumPadding / 2),
    controller: controller,
    tabs: tabs,
    onTap: onTap,
  ),

Flutter Doctor output

[✓] Flutter (Channel stable, 3.32.6, on Ubuntu Questing Quokka (development branch) 6.15.5-061505-generic, locale
    en_DE.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1.2)
[✓] Connected device (2 available)
[✓] Network resources

Activity

  1. tirth-patel-nc commented on Jul 10, 2025

    @tirth-patel-nc
    Member

    hi @qeepcologne, thanks for the report. I've simplified your snippet to a minimal reproducible example. Seeing the same behaviour with latest SDK versions. I've set indicatorWeight: 100, but it doesn't seem to be ignored even though an indicator is provided via TabBarThemeData.

    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(
          theme: ThemeData(
            tabBarTheme: TabBarThemeData(
              indicator: BoxDecoration(
                color: Colors.blue,
                borderRadius: BorderRadius.circular(8),
                border: Border.all(color: Colors.black),
              ),
              indicatorColor: Colors.red, // ignored
              indicatorSize: TabBarIndicatorSize.tab,
            ),
          ),
          home: const TabBarExample(),
        );
      }
    }
    
    class TabBarExample extends StatefulWidget {
      const TabBarExample({super.key});
      @override
      State<TabBarExample> createState() => _TabBarExampleState();
    }
    
    class _TabBarExampleState extends State<TabBarExample>
        with TickerProviderStateMixin {
      late TabController controller;
    
      @override
      void initState() {
        super.initState();
        controller = TabController(length: 2, vsync: this);
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            bottom: TabBar(
              controller: controller,
              tabs: const [
                Tab(text: 'One'),
                Tab(text: 'Two'),
              ],
              indicatorWeight: 100, // should be ignored
            ),
          ),
          body: TabBarView(
            controller: controller,
            children: const [
              Center(child: Text('One')),
              Center(child: Text('Two')),
            ],
          ),
        );
      }
    }
    stable : 3.32.6
    master : 3.33.0-1.0.pre.905
    
    Image
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    team-designOwned by Design Languages team
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Jul 10, 2025
  3. changed the title [-]TabBar indicatorWeight (defaults 2 even if indicator provided in TabBarTheme)[/-] [+]TabBar indicatorWeight is not ignored as documented [/+] on Jul 10, 2025
  4. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Jul 10, 2025
  5. self-assigned this
    on Jul 11, 2025
  6. 3 remaining items

  7. flutter-triage-bot commented on Dec 1, 2025

    @flutter-triage-bot

    This issue is assigned to @huycozy but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  8. removed their assignment
    on Dec 1, 2025
  9. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Dec 1, 2025
  10. saurabh-mirajkar commented on Mar 24, 2026

    @saurabh-mirajkar
    Contributor

    Based on the investigation and code references above by @huycozy, it seems that indicatorWeight is still used internally for computing the preferredSize of the TabBar, even when a custom indicator is provided.

    Given that preferredSize does not have access to BuildContext, this behavior appears intentional or constrained by design.

    Instead of changing behavior (which could have backward compatibility implications), I think the documentation could be clarified to state that:

    • indicatorWeight does not affect indicator painting when a custom indicator is provided
    • but it may still influence layout size

    I can work on a documentation update PR if this direction makes sense.

  11. QuncCccccc commented on Mar 25, 2026

    @QuncCccccc
    Contributor

    Thanks for your both analysis @huycozy @saurabh-mirajkar! And I think a doc update PR makes sense to me.

  12. saurabh-mirajkar commented on Mar 25, 2026

    @saurabh-mirajkar
    Contributor

    @QuncCccccc Submitted a PR to clarify the documentation around indicatorWeight behavior when a custom indicator is provided. Would appreciate feedback!

  13. github-actions commented on Apr 13, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work listfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions