skip to Main Content

Here is my code ,it is showing errors like The named parameter
‘accentColor’ isn’t defined.Try correcting the name to an existing named parameter’s name, or defining a named parameter with the name ‘accentColor’.and the same with parameter ‘brightness’.

  import 'package:flutter/material.dart';
    // import 'package:rangkings/config/config.dart';    
    // import '../config/config.dart';
    
    class ThemeModel {
      final lightMode = ThemeData(
        primarySwatch: Colors.blue,
        primaryColor: Color(0xFF3A52BC),
        accentColor: Colors.white,
        iconTheme: IconThemeData(color: Colors.white),
        fontFamily: 'Manrope',
        scaffoldBackgroundColor: Colors.white,
        brightness: Brightness.light,
        primaryColorDark: Colors.grey[800],
        primaryColorLight: Colors.white,
        secondaryHeaderColor: Colors.grey[600],
        shadowColor: Colors.grey[200],
        backgroundColor: Colors.white,
        appBarTheme: AppBarTheme(
          brightness: Brightness.light,
          color: Color(0xFF3A52BC),
          elevation: 0,
          iconTheme: IconThemeData(
            // color: Colors.grey[900],
            color: Colors.white,
          ),
          actionsIconTheme: IconThemeData(color: Colors.grey[900]),
          // textTheme: TextTheme(
          //   headline6: TextStyle(
          //     fontFamily: 'Manrope',
          //     fontSize: 18,
          //     fontWeight: FontWeight.w700,
          //     // color: Colors.grey[900],
          //     color: Colors.white,
          //   ),
          // ),
        ),
        textTheme: TextTheme(
          subtitle1: TextStyle(
              fontWeight: FontWeight.w500, fontSize: 16, color: Colors.grey[900]),
          bodyText2: TextStyle(
              fontWeight: FontWeight.w500, fontSize: 16, color: Colors.grey[900]),
        ),
        bottomNavigationBarTheme: BottomNavigationBarThemeData(
          backgroundColor: Colors.white,
          selectedItemColor: Color(0xFF3A52BC),
          unselectedItemColor: Colors.grey[500],
        ),
      );
    
      final darkMode = ThemeData(
          primarySwatch: Colors.deepPurple,
          primaryColor: Color(0xFF3A52BC),
          accentColor: Colors.white,
          iconTheme: IconThemeData(color: Colors.white),
          fontFamily: 'Manrope',
          scaffoldBackgroundColor: Color(0xff303030),
          brightness: Brightness.dark,
          primaryColorDark: Colors.grey[300],
          primaryColorLight: Colors.grey[800],
          secondaryHeaderColor: Colors.grey[400],
          shadowColor: Color(0xff282828),
          backgroundColor: Colors.grey[900],
          appBarTheme: AppBarTheme(
            brightness: Brightness.dark,
            color: Colors.grey[900],
            elevation: 0,
            iconTheme: IconThemeData(
              color: Colors.white,
            ),
            actionsIconTheme: IconThemeData(color: Colors.white),
            // textTheme: TextTheme(
            //   headline6: TextStyle(
            //     fontFamily: 'Manrope',
            //     fontSize: 18,
            //     fontWeight: FontWeight.w700,
            //     color: Colors.white,
            //   ),
            // ),
          ),
          textTheme: TextTheme(
            subtitle1: TextStyle(
                fontWeight: FontWeight.w500, fontSize: 16, color: Colors.white),
          ),
          bottomNavigationBarTheme: BottomNavigationBarThemeData(
            backgroundColor: Colors.grey[900],
            selectedItemColor: Colors.white,
            unselectedItemColor: Colors.grey[500],
          ));
    }

Give an efficient solution for this errors,only those 4 errors are showing 2 accentColor one’s and 2 brightness.

3

Answers


  1. Regarding accentColor, According to Flutter documentation

    The ThemeData accentColor, accentColorBrightness, accentIconTheme and accentTextTheme properties have been deprecated.
    The Material Design spec no longer specifies or uses an “accent” color for the Material components. The default values for component colors are derived from the overall theme’s color scheme. The ColorScheme’s secondary color is now typically used instead of accentColor and the onSecondary color is used when a contrasting color is needed.

    Read more here https://docs.flutter.dev/release/breaking-changes/theme-data-accent-properties

    Login or Signup to reply.
  2. we don’t have accent color and brightness in ThemeData in current version of flutter anymore

    Login or Signup to reply.
  3. Both accentColor and brightness are deprecated, use colorScheme.secondary to replace accentColor, and systemOverlayStyle to replace brightness.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search