Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

appbar icons aren't being effected by the themedata

I’m trying to set up the themedata for my app and i can’t get the color of the icons in the app bar to change.

import 'package:flutter/material.dart';


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

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

  static const primaryColor = Color(0xFF0A0E21);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        appBarTheme: AppBarTheme(
          color: primaryColor,
          iconTheme: IconThemeData(
            color: Colors.white,
            size: 40,
          ),
          foregroundColor: Colors.white,
        ),
        scaffoldBackgroundColor: primaryColor,
        textTheme: TextTheme(
          bodyText1: TextStyle(
            fontWeight: FontWeight.bold,
            fontFamily: 'SourceSansPro',
          ),
        ),
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: Text('HELLO'),
          toolbarHeight: 60.0,
          //centerTitle: true,

          actions: [
            IconButton(
              onPressed: null,
              icon: Icon(
                Icons.settings,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

I can change the color in the appbar widget itself but i don’t want to do that over multiple pages.

weirdly enough, the size parameter in the IconThemeData is having an effect. but not the color.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

i’ve also tried a full restart of the emulator too.

any help would be greatly appreciated.

>Solution :

For IconButton‘s , It is using disabledColor color by default.

You can check by

 theme: ThemeData.dark().copyWith(
        disabledColor: Colors.white,

Also for your case, you can do

icon: Icon(
  Icons.settings,
  color: Theme.of(context).iconTheme.color,
),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading