After upgrading to Flutter 3.50, flutter analyze reports this on almost every file:
info - 'package:flutter/material.dart' is deprecated and shouldn't be used.
Use package:material_ui/material_ui.dart instead.
This feature was deprecated after v3.47.0-0.0.pre. - lib/main.dart:1:1 - deprecated_member_use
The same happens for package:flutter/cupertino.dart, which points you to package:cupertino_ui/cupertino_ui.dart.
Your app still builds and runs. This is a deprecation, not an error. But it’s worth fixing now, because deprecated APIs are eventually removed, and new Flutter projects already use the new imports.
What changed
The Material and Cupertino widget libraries moved out of the Flutter SDK into their own packages on pub.dev:
| Before (deprecated) | Now | Package |
|---|---|---|
package:flutter/material.dart |
package:material_ui/material_ui.dart |
material_ui |
package:flutter/cupertino.dart |
package:cupertino_ui/cupertino_ui.dart |
cupertino_ui |
The widgets themselves are the same: Scaffold, ElevatedButton, ThemeData, CupertinoButton and the rest keep their names. Only the import and the dependency change. A project created with flutter create on 3.50 already imports material_ui and lists material_ui: ^1.1.0 in its pubspec.yaml.
package:flutter/widgets.dart is not affected.
Migrate in one command
From your project root:
dart fix --dry-run # shows what will change
dart fix --apply
flutter pub get
On a test project, dart fix --apply did three things:
- Replaced
import 'package:flutter/material.dart';withimport 'package:material_ui/material_ui.dart'; - Replaced
import 'package:flutter/cupertino.dart';withimport 'package:cupertino_ui/cupertino_ui.dart'; - Added the missing dependency to pubspec.yaml
One catch: for a package that wasn’t listed yet, the fix wrote cupertino_ui: any. Replace any with a real version constraint so a future major release can’t break your build unexpectedly:
flutter pub add material_ui cupertino_ui
That writes caret constraints like ^1.x.y for the current versions. Then run flutter analyze again; the deprecation infos should be gone.
Packages and generated code
- Your own packages in the same repo (a
packages/folder or a melos workspace): rundart fix --applyinside each one. - Third-party packages that still import
package:flutter/material.dartkeep working; the warning is theirs to fix and doesn’t show in your analyzer output for your own code. Update them when new versions come out. The Flutter package checker shows which packages in your pubspec are behind. - Generated files (
*.g.dart,*.freezed.dart) usually don’t import Material. If one does, regenerate it after upgrading the generator. - Code snippets, tutorials and AI-generated code written before Flutter 3.47 use the old import. They still work, but switch the import when you paste them in.
Should you migrate right away?
If you’re on Flutter 3.50 or later, yes. It’s a mechanical change that takes minutes and keeps the analyzer clean, which matters if your CI fails on infos. Do it in its own commit, separate from feature work, so it’s easy to review.
If your project is still on an older Flutter (for example 3.35), stay on package:flutter/material.dart until you upgrade. Plan the upgrade around the rest of the toolchain too: Flutter 3.50 projects use Android Gradle Plugin 9.3.1, Gradle 9.5.0 and Kotlin 2.4.20, which brings its own Kotlin and Gradle/Java errors.
Frequently asked questions
Why is package:flutter/material.dart deprecated?
Material and Cupertino widgets moved out of the Flutter SDK into separate pub.dev packages, material_ui and cupertino_ui, starting with Flutter 3.47. The old library is marked deprecated and points to the new import.
How do I fix the material.dart deprecated warning?
Run dart fix –apply in your project. It replaces the import with package:material_ui/material_ui.dart and adds material_ui to pubspec.yaml. Then run flutter pub get and flutter analyze.
Do I need to rename any widgets?
No. Scaffold, AppBar, ThemeData, CupertinoButton and the other widgets keep the same names and APIs. Only the import line and the dependency change.
Will my app break if I don't migrate?
Not now. The old import is deprecated, not removed, so the app builds and runs. Deprecated APIs are removed in later releases, so migrate before that happens.
Stuck on a build or a store release? I fix and maintain Flutter apps, or tell me about your project. More fixes: all Flutter answers.