Skip to content

TabBar labelStyle.color and unselectedLabelStyle.color does not take effect #109484

@dayveedaniel

Description

@dayveedaniel

Steps to Reproduce

1.(similar issue #67342 but on tab bar) Execute flutter run on the code sample

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


class MyApp extends StatelessWidget{

  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>  with SingleTickerProviderStateMixin {

  late final TabController _controller;

  @override
  void initState() {
    super.initState();
    _controller = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Column(
        children: [
          Container(
            decoration: BoxDecoration(
              color: AppColors.background,
              borderRadius: BorderRadius.circular(12),
            ),
            child: TabBar(
              controller: _controller,
              labelStyle:TextStyle(
                fontWeight: FontWeight.w700,
                fontSize: 14,
                color:  Colors.white
              ),
              unselectedLabelStyle:
              TextStyle(
                  fontWeight: FontWeight.w700,
                  fontSize: 14,
                  color:  Colors.black
              ),
              indicator: BoxDecoration(
                  color: Colors.teal,
                  borderRadius: BorderRadius.circular(8)),
              tabs: [
                Tab(text: 'Tab 1'),
                Tab(text: 'Tab 2'),
              ],
            ),
          ),
          Expanded(
            child: TabBarView(
              controller: _controller,
                children: [
              Text('tab 1'),
              Text('tab 2'),
            ]),
          )
        ],
      )

    );
  }
}

Expected results: unselected tab text color should be black

Actual results: unselected tab text color is same as selected tab

Logs
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19043.1889],)
    • Flutter version 3.0.5 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Users\asus\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.

tab 1 tab 2
image image

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.found in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1frameworkflutter/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 versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions