Flutter: A value of type 'ListTileThemeData' can't be assigned to a variable of type 'ListTileTheme'
I am posting this question to help future readers. After upgrading to Flutter 2.8
I suddenly got this error when trying to run my app:
Flutter: A value of type 'ListTileThemeData' can't be assigned to a variable of type 'ListTileTheme'.
How did I fix this?
Solution 1:
Turns out this error was caused by a popular library I used (settings_ui
) that does not work with this version of Flutter (settings_ui: ^1.0.0
).
For future readers: Use a later version of this package. There is currently an open issue on github that addresses this.
Update 2022: Dev on settings_ui seems to have gone AWOL and no longer merging PR's the community has forked this project to: https://pub.dev/packages/flutter_settings_ui and here updates are properly merged and a fix has been released in version 1.0.1
For people facing this issue now:
As a monkey patch you can follow the steps in the GitHub issue and edit the package files locally:
In cupertino_settings_item.dart
change final ListTileTheme tileTheme = ListTileTheme.of(context);
to final tileTheme = ListTileTheme.of(context);
And change _iconColor(ThemeData theme, ListTileTheme tileTheme)
to _iconColor(ThemeData theme, ListTileThemeData tileTheme)
.
Solution 2:
Update flutter_settings_ui: ^2.0.1 to latest and save.
import 'package:flutter_settings_ui/flutter_settings_ui.dart';
Save and flutter run solves this issue.