Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The named Parameters are not defined error

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.

like image 511
Sanjeet Chukka Avatar asked Mar 09 '26 17:03

Sanjeet Chukka


1 Answers

Both accentColor and brightness are deprecated, use colorScheme.secondary to replace accentColor, and systemOverlayStyle to replace brightness.

like image 112
Zhentao Avatar answered Mar 12 '26 07:03

Zhentao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!