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

what is the alternative for accentColor Flutter

I’m new to flutter. working on a chat app. I have created a app bar but the colors I added in main.dart not display. it just display as default blue color. how to correct??

enter image description here

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      //title: 'Profile Section',
      theme: ThemeData(
        primaryColor: Color(0xff075e54),
        accentColor: Color(0xff128C7E)),
        home: Homescreen(key: null),

    );
  }
}

homescreen.dart

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

import 'package:flutter/material.dart';


class Homescreen extends StatefulWidget {
  Homescreen({ Key? key }) : super(key: key);


  @override
  _HomescreenState createState() => _HomescreenState();
}

class _HomescreenState extends State<Homescreen> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Whatsapp Clone"),
        actions: [
          IconButton(icon: Icon(Icons.search), onPressed: () {}),
          IconButton(icon: Icon(Icons.more_vert), onPressed: () {}),
    ],
    ),
    );
  }
}

>Solution :

Use this, as your code. It should work.

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  final ThemeData theme = ThemeData(); //You need to make a var, that works as ThemeData

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      //title: 'Profile Section',
      theme: theme.copyWith(
        colorScheme: theme.colorScheme.copyWith(primary: Color(0xff075e54),secondary: Color(0xff128C7E), //Then use it with colorScheme.
     ),
     ),
     home: Homescreen(key: null),
    );
  }
}
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