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
Regarding
accentColor
, According to Flutter documentationRead more here https://docs.flutter.dev/release/breaking-changes/theme-data-accent-properties
we don’t have accent color and brightness in ThemeData in current version of flutter anymore
Both
accentColor
andbrightness
are deprecated, usecolorScheme.secondary
to replaceaccentColor
, andsystemOverlayStyle
to replacebrightness
.