Skip to content

feat!: migrate to the decoupled material_ui package - #135

Merged
yadaniyil merged 3 commits into
yako-dev:masterfrom
mayainle:feat/migrate-to-material-ui
Sep 24, 2026
Merged

yadaniyil merged 3 commits into
yako-dev:masterfrom
mayainle:feat/migrate-to-material-ui

Conversation

@mayainle

Copy link
Copy Markdown
Contributor

Material and Cupertino moved out of the SDK into their own packages in Flutter 3.47. Right now apps that have migrated can't really use badges, because Dart treats ThemeData from package:flutter/material.dart and from package:material_ui as different types, so you can't pass your theme or colors into this package.

What I did:

  • ran dart fix --apply --code=migrate_design_widgets, the official migration (31 files, imports only)
  • added material_ui: ^1.4.0 and bumped to 4.0.0, since the Flutter team asks packages to treat this as a major release
  • raised the SDK constraints to the minimum material_ui needs, Dart 3.13.0 and Flutter 3.47.0
  • updated the README section explaining how to avoid the ambiguous Badge import

Two things I changed by hand:

dart fix also wanted to add cupertino_ui. The only file importing cupertino was badge_gradient_type.dart, which is just an enum. The import is only there so the LinearGradient, RadialGradient and SweepGradient references in its doc comments resolve, and those come from painting. So I switched that file to package:flutter/widgets.dart and left cupertino_ui out. No new dependency apart from material_ui.

I also replaced SizeTransition.axisAlignment with alignment. The old one has been deprecated since v3.41 and was showing up in analyze. I used the mapping from the SDK docs. BadgeAnimation.sizeTransitionAxisAlignment still takes a double, so nothing changes for users.

Tests: 175/175 pass, same as before the migration. flutter analyze is clean now, it had one deprecation warning before.

mayainle and others added 3 commits September 23, 2026 22:09
Material and Cupertino ship as standalone packages from Flutter 3.47.
Applied `dart fix --apply --code=migrate_design_widgets` and raised the
SDK floor to the minimum material_ui requires (Dart 3.13, Flutter 3.47).

badge_gradient_type.dart imported package:flutter/cupertino.dart only so
its doc-comment gradient references resolve, so it moves to
package:flutter/widgets.dart rather than pulling in cupertino_ui.

Also replaces SizeTransition.axisAlignment, deprecated after v3.41, with
alignment, using the mapping the SDK documents. The public
BadgeAnimation.sizeTransitionAxisAlignment double is unchanged.
- Run `dart format .`: raising the SDK floor to 3.13 switches the
  formatter to the tall style, so CI's format check failed on 16 files.
- example/pubspec.yaml: require Dart 3.13 / Flutter 3.47, which
  material_ui needs.
- CHANGELOG: describe what actually changes for apps on material_ui
  vs package:flutter/material.dart.
- README: keep the flutter/material.dart `hide Badge` import for apps
  that haven't migrated yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The example's SDK floor is now 3.13 too, so its files use the tall style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yadaniyil
yadaniyil merged commit 4e7932c into yako-dev:master Sep 24, 2026
2 checks passed
@yadaniyil

Copy link
Copy Markdown
Collaborator

Thanks a lot for this, and for the careful write-up! The cupertino_ui and axisAlignment notes were really helpful. The alignment mapping is correct on both axes and in RTL; we measured it.

We tested it on iOS and Android, and the example looks pixel-identical to before. I pushed two small commits to your branch before merging:

  • dart format .: raising the SDK floor to Dart 3.13 switches the formatter to the tall style, so CI's format check failed.
  • example/pubspec.yaml now requires Dart 3.13 / Flutter 3.47 like material_ui, and I reworded the CHANGELOG a bit: apps still on package:flutter/material.dart keep working, only the badge's default text style differs until they migrate.

This ships in 4.0.0, together with a batch of bug fixes. Thanks again! 🙏

@yadaniyil

Copy link
Copy Markdown
Collaborator

4.0.0 with your migration is now live on pub.dev: https://pub.dev/packages/badges/versions/4.0.0 🎉 Release notes: https://github.com/yako-dev/flutter_badges/releases/tag/v4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants