Repository navigation
Commit 3675456
authored
[material_ui] Fallback theme follows platform cherry pick (#13278)
**Port of: flutter/flutter#194256
**Issue:** `Theme.of(context)` falls back to a `ThemeData` built once per isolate (`Theme._kFallbackTheme`) when there is no `Theme` ancestor. `ThemeData()` captures `defaultTargetPlatform` at construction, so the fallback's platform is frozen to whatever platform was in effect the first time a theme-less widget called `Theme.of(context)`. Under a `TargetPlatformVariant`, `debugDefaultTargetPlatformOverride` every later theme-less subtree keeps that first platform's selection controls, toolbar, cursor and other adaptive behavior. In a shuffled test run this makes theme-less tests depend on test order: with seed 20261008, text_field_test.dart fails 45 tests that pass in declaration order.
**Fix:** Rebuild the cached fallback whenever its platform no longer matches `defaultTargetPlatform`, so a theme-less subtree adapts to the current platform the same way a `MaterialApp` does. `Theme`s built with an explicit platform are unaffected; only the fallback is compared. Adds a regression test in `theme_test.dart` that fails on master for every non-android variant.
With the fallback following the variant, the two handle-drag tests in `text_field_test.dart` fail because they had only ever run against Android handles: desktop platforms draw no selection handles, and the Cupertino start handle sits above the line. These tests have been adjusted; restricted to the platforms that draw handles, the iOS start handle is grabbed where it actually is, the Fuchsia toolbar that covers the handles is hidden, and a test asserts that desktop platforms draw no handles. The orphaned no-shuffle tag is removed.
**Other alternatives considered:**
- `text_field_test.dart` only fix, tests explicitly install their own theme so `Theme.of(context)` does not return leaky fallback. Decided against this since it wouldn't fix this leak for all users as reported in #83788
Fixes [#83788](flutter/flutter#83788)
Fixes [#194008](flutter/flutter#194008)
## Pre-Review Checklist
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). 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.
[^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.1 parent df2c368 commit 3675456
4 files changed
Lines changed: 162 additions & 109 deletions
File tree
- packages/material_ui
- lib/src
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
134 | 148 | | |
135 | 149 | | |
136 | 150 | | |
137 | | - | |
| 151 | + | |
138 | 152 | | |
139 | 153 | | |
140 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3170 | 3170 | | |
3171 | 3171 | | |
3172 | 3172 | | |
3173 | | - | |
3174 | | - | |
3175 | | - | |
3176 | | - | |
| 3173 | + | |
| 3174 | + | |
3177 | 3175 | | |
3178 | | - | |
3179 | | - | |
3180 | | - | |
3181 | | - | |
3182 | | - | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
3183 | 3181 | | |
3184 | | - | |
3185 | | - | |
3186 | | - | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
3187 | 3185 | | |
3188 | | - | |
3189 | | - | |
3190 | | - | |
3191 | | - | |
3192 | | - | |
3193 | | - | |
3194 | | - | |
3195 | | - | |
3196 | | - | |
3197 | | - | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
3198 | 3196 | | |
3199 | | - | |
3200 | | - | |
3201 | | - | |
3202 | | - | |
3203 | | - | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
3204 | 3202 | | |
3205 | | - | |
3206 | | - | |
3207 | | - | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
3208 | 3206 | | |
3209 | | - | |
3210 | | - | |
3211 | | - | |
3212 | | - | |
3213 | | - | |
3214 | | - | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
3215 | 3213 | | |
3216 | | - | |
3217 | | - | |
3218 | | - | |
3219 | | - | |
3220 | | - | |
3221 | | - | |
3222 | | - | |
3223 | | - | |
3224 | | - | |
3225 | | - | |
3226 | | - | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
3227 | 3225 | | |
3228 | | - | |
3229 | | - | |
| 3226 | + | |
| 3227 | + | |
3230 | 3228 | | |
3231 | | - | |
3232 | | - | |
3233 | | - | |
3234 | | - | |
3235 | | - | |
3236 | | - | |
3237 | | - | |
3238 | | - | |
3239 | | - | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
3240 | 3240 | | |
3241 | | - | |
3242 | | - | |
3243 | | - | |
3244 | | - | |
3245 | | - | |
3246 | | - | |
3247 | | - | |
3248 | | - | |
3249 | | - | |
3250 | | - | |
3251 | | - | |
3252 | | - | |
3253 | | - | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
3254 | 3244 | | |
3255 | | - | |
3256 | | - | |
3257 | | - | |
3258 | | - | |
3259 | | - | |
3260 | | - | |
3261 | | - | |
3262 | | - | |
3263 | | - | |
3264 | | - | |
3265 | | - | |
3266 | | - | |
3267 | | - | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
3268 | 3258 | | |
3269 | | - | |
3270 | | - | |
3271 | | - | |
3272 | | - | |
3273 | | - | |
3274 | | - | |
3275 | | - | |
3276 | | - | |
3277 | | - | |
3278 | | - | |
3279 | | - | |
3280 | | - | |
3281 | | - | |
3282 | | - | |
3283 | | - | |
3284 | | - | |
3285 | | - | |
3286 | | - | |
3287 | | - | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
3288 | 3263 | | |
3289 | 3264 | | |
3290 | | - | |
| 3265 | + | |
3291 | 3266 | | |
3292 | 3267 | | |
3293 | 3268 | | |
| |||
3315 | 3290 | | |
3316 | 3291 | | |
3317 | 3292 | | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
3318 | 3298 | | |
3319 | 3299 | | |
3320 | 3300 | | |
| |||
3389 | 3369 | | |
3390 | 3370 | | |
3391 | 3371 | | |
3392 | | - | |
3393 | | - | |
3394 | | - | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
3395 | 3376 | | |
3396 | 3377 | | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
3397 | 3416 | | |
3398 | 3417 | | |
3399 | 3418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
229 | 246 | | |
230 | 247 | | |
231 | 248 | | |
| |||
0 commit comments