'Warning: Operand of null-aware operation '??' has type 'Color' which excludes null

I have upgrade flutter version to 2.0.4, when I run the project(this project was runing on old flutter version)it throws warning because of package I used.

this is the package that I used : https://pub.dev/packages/flutter_datetime_picker

and this is the error:

../../../flutter2/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.5.1/lib/flutter_datetime_picker.dart:311:32: Warning: Operand of null-aware operation '??' has type 'Color' which excludes null.
 - 'Color' is from 'dart:ui'.
                  color: theme.backgroundColor ?? Colors.white,


Solution 1:[1]

This is a warning, not an error. It simply means that ?? Colors.white is unnecessary, since theme.backgroundColor will never be null. Aside from an annoying message every time you use flutter run, this should not negatively affect your app.

According to the library's issue tracker, this is a known issue which has already been fixed, but that fix hasn't made it into any releases yet.

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 Nitrodon