'I built an app in flutter but during run time i get A secondary container isnt defined for ColorScheme error

Launching lib\main.dart on SOV36 in debug mode... lib\main.dart:1 : Error: The getter 'secondaryContainer' isn't defined for the class 'ColorScheme'. ../…/pointers/marker_pointer_renderer.dart:631

  • 'ColorScheme' is from 'package:flutter/src/material/color_scheme.dart' ('../flutter/packages/flutter/lib/src/material/color_scheme.dart'). package:flutter/…/material/color_scheme.dart:1 Try correcting the name to the name of an existing getter, or defining a getter or field named 'secondaryContainer'. _themeData.colorScheme.secondaryContainer.withOpacity(0.8) ^^^^^^^^^^^^^^^^^^

: Error: The getter 'secondaryContainer' isn't defined for the class 'ColorScheme'. ../…/pointers/marker_pointer_renderer.dart:642

  • 'ColorScheme' is from 'package:flutter/src/material/color_scheme.dart' ('../flutter/packages/flutter/lib/src/material/color_scheme.dart'). package:flutter/…/material/color_scheme.dart:1 Try correcting the name to the name of an existing getter, or defining a getter or field named 'secondaryContainer'. _themeData.colorScheme.secondaryContainer.withOpacity(0.12) ^^^^^^^^^^^^^^^^^^ : Error: The getter 'secondaryContainer' isn't defined for the class 'ColorScheme'. ../…/pointers/range_pointer_renderer.dart:567
  • 'ColorScheme' is from 'package:flutter/src/material/color_scheme.dart' ('../flutter/packages/flutter/lib/src/material/color_scheme.dart'). package:flutter/…/material/color_scheme.dart:1 Try correcting the name to the name of an existing getter, or defining a getter or field named 'secondaryContainer'. _themeData.colorScheme.secondaryContainer.withOpacity(0.8) ^^^^^^^^^^^^^^^^^^ 2

FAILURE: Build failed with an exception.

  • Where: Script 'C:\Users\JONAH\Documents\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1070

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\Users\JONAH\Documents\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


Solution 1:[1]

Try upgrade flutter.

flutter upgrade
 
flutter pub upgrade

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ouflak