feat!: migrate to the decoupled material_ui package (fixes #237) - #239
Open
qeepcologne wants to merge 1 commit into
Open
feat!: migrate to the decoupled material_ui package (fixes #237)#239qeepcologne wants to merge 1 commit into
qeepcologne wants to merge 1 commit into
Conversation
|
@Tkko please merge this, if we use this package in the current version we can't upgrade flutter sdk to 3.47 |
Owner
|
Hey guys, please use the workaround mentioned here while I'm investigating if I can somehow fully remove the material dependency |
|
Hi @Tkko, thanks for letting us know that you're at least going to look into it; let us know if there's anything we can do on our end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #237.
Material was decoupled from the Flutter SDK into the
material_uipackage. The in-SDKpackage:flutter/material.dartis frozen to contributions and scheduled for removal, so pinput needs to move for apps that have already migrated.The bug
_PinputState.buildassertsdebugCheckHasMaterial(context), which resolves the ancestor withLookupBoundary.findAncestorWidgetOfExactType<Material>— an exact type match. Amaterial_uiapp'sScaffoldprovidesmaterial_ui'sMaterial, a different class, so the assert always fails:It throws out of
build(), so Flutter substitutes anErrorWidgetand the field never renders.assertis debug-only, so release builds are unaffected — which makes it easy to miss: the screen works in release and red-screens underflutter run.MaterialUiCompatibilityBridgedoes not help. It supplies a legacyThemeandLocalizations, never a legacyMaterialancestor. The workaround in #237 (wrapping eachPinputinold.Material(type: transparency)) works but pushes a legacy import back into apps that just removed theirs.What changed
Import swap only, no logic touched. The whole library is one import line — 11 of the 13 files under
lib/srcarepart of '../pinput.dart'. Also swappedtest/andexample/so they exercise the real target.Everything pinput uses exists in
material_uiwith identical semantics:Theme,ThemeData,Colors,TextField(docs),AdaptiveTextSelectionToolbar, and bothdebugCheckHasMaterial*helpers. After the swap the asserts resolve againstmaterial_ui, so amaterial_uiScaffoldsatisfies them.Worth noting the two asserts are not equivalent, in case removing them was on the table as an alternative fix:
debugCheckHasMaterialLocalizationsguards something real, since the defaultcontextMenuBuilderisAdaptiveTextSelectionToolbar.editableText, which readsMaterialLocalizationsat runtime for the cut/copy/paste labels. OnlydebugCheckHasMaterialis decorative — pinput never callsMaterial.of, draws no ink, andTextSelectionToolbarbuilds its ownMaterial. Migrating keeps both correct rather than trading one problem for another.pubspec.yaml:material_ui: ^1.0.0,sdk: >=3.12.0,flutter: >=3.44.0— the floormaterial_uiitself declares, not higher. This supersedes fix: bump minimum Flutter SDK to 3.27.0 to fix TapRegionUpCallback not found ( #227, #229) #234, which raised the floor to 3.27.0 for an unrelated reason.Pinputcan only satisfy oneMaterialuniverse: 6.x stays the path for apps still onpackage:flutter/material.dart.Verification
flutter analyze lib/ test/ example/— no errors or warnings.flutter test— 12/12 pass.material_uiapp:ErrorWidget: 1,EditableText: 0. With this branch and no workaround wrapper: no exception,EditableText: 1.material_uiapp (~450 Dart files, Flutter 3.47.1): analyze clean, test suite green, release-flavour APK builds.