Skip to content

[material_ui, cupertino_ui] Add migration bridge utilities - #12314

Merged
auto-submit[bot] merged 3 commits into
flutter:mainfrom
Piinks:designBridges
Jul 30, 2026
Merged

[material_ui, cupertino_ui] Add migration bridge utilities#12314
auto-submit[bot] merged 3 commits into
flutter:mainfrom
Piinks:designBridges

Conversation

@Piinks

@Piinks Piinks commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This adds utilities to the material_ui and cupertino_ui to help cover the gap during the ecosystem migration. Users who have migrated their applications can use these utilities to retain compatibility with packages that have not migrated yet.
These are marked deprecated as they will be removed in a future major release.

Example:

import 'package:material_ui/material_ui.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF6750A4)),
      ),
      builder: (BuildContext context, Widget? child) {
        return MaterialUiCompatibilityBridge(child: child!);
      },
      home: const HomeScreen(),
    );
  }
}

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces CupertinoUiCompatibilityBridge and MaterialUiCompatibilityBridge to facilitate migration by mapping modern theme and localization configurations to their legacy equivalents. Feedback on the changes suggests mapping the platform and visualDensity properties in MaterialUiCompatibilityBridge to ensure consistent platform-specific behaviors and layout densities.

Comment on lines +116 to +117
return legacy.ThemeData(
colorScheme: legacy.ColorScheme(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The platform and visualDensity properties are not mapped from modernTheme to the legacy ThemeData. This can cause inconsistent platform-specific behaviors (e.g., scroll physics, adaptive widgets) and layout densities for legacy widgets inside the bridge. Consider mapping these properties as well.

Suggested change
return legacy.ThemeData(
colorScheme: legacy.ColorScheme(
return legacy.ThemeData(
platform: modernTheme.platform,
visualDensity: modernTheme.visualDensity,
colorScheme: legacy.ColorScheme(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch Gemini, or did you purposely omit these @Piinks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a good catch!

@github-actions github-actions Bot added the triage-framework Should be looked at in framework triage label Jul 29, 2026
@Piinks
Piinks requested a review from justinmc July 29, 2026 21:59
Comment thread packages/material_ui/lib/src/migration_utility.dart

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

// found in the LICENSE file.

import 'package:cupertino_ui/cupertino_ui.dart' as modern; // ignore: prefer_relative_imports
import 'package:flutter/cupertino.dart' as legacy;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep an eye out for any side effects of this import, but I can't think of any specific reason why it should complicate things.

Comment on lines +76 to +78
expect(capturedLegacyTheme!.textTheme.navTitleTextStyle.fontSize, 20.0);
expect(capturedLegacyTheme!.textTheme.navTitleTextStyle.fontWeight, FontWeight.bold);
expect(capturedLegacyTheme!.textTheme.actionTextStyle.color, const Color(0xFF123456));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would compare with modernTextTheme.navTitleTextStyle.fontSize instead of hard coding 20.0, and so on. That way it's clear to a reader where that value came from, and there's less chance of things getting out of sync.

Comment thread packages/material_ui/lib/src/migration_utility.dart
Comment on lines +116 to +117
return legacy.ThemeData(
colorScheme: legacy.ColorScheme(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch Gemini, or did you purposely omit these @Piinks?

@Piinks
Piinks requested a review from justinmc July 30, 2026 18:15
@Piinks

Piinks commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Feedback addressed, PTAL! 🙂

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 30, 2026
@auto-submit
auto-submit Bot merged commit 5351d8c into flutter:main Jul 30, 2026
13 checks passed
pull Bot pushed a commit to ScorpiusDraconis83/flutter that referenced this pull request Jul 31, 2026
…r#190351)

flutter/packages@7d17fc8...5351d8c

2026-07-30 katelovett@google.com [material_ui, cupertino_ui] Add
migration bridge utilities (flutter/packages#12314)
2026-07-30 269567208+reidbaker-agent@users.noreply.github.com Enforce
scoped validation tools in AGENTS.md with file-based trap evals
(flutter/packages#12297)
2026-07-30 engine-flutter-autoroll@skia.org Manual roll Flutter from
c83f80b to 2a230d1 (6 revisions) (flutter/packages#12325)
2026-07-30 engine-flutter-autoroll@skia.org Manual roll Flutter from
0f02463 to c83f80b (7 revisions) (flutter/packages#12318)
2026-07-30 kirill.webmail@yandex.com [camera_android_camerax] Prefer
higher resolution for max preset (flutter/packages#11956)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: cupertino_ui p: material_ui triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants