Repository navigation
Commit 98a4d30
**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 flutter#83788
**This will still need a follow up PR that does the same change in
`material_ui`**
Fixes flutter#83788
Fixes flutter#194008
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
1 parent e25ce61 commit 98a4d30
3 files changed
Lines changed: 159 additions & 109 deletions
| 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 | |
|---|---|---|---|
| |||
3169 | 3169 | | |
3170 | 3170 | | |
3171 | 3171 | | |
3172 | | - | |
3173 | | - | |
3174 | | - | |
3175 | | - | |
| 3172 | + | |
| 3173 | + | |
3176 | 3174 | | |
3177 | | - | |
3178 | | - | |
3179 | | - | |
3180 | | - | |
3181 | | - | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
3182 | 3180 | | |
3183 | | - | |
3184 | | - | |
3185 | | - | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
3186 | 3184 | | |
3187 | | - | |
3188 | | - | |
3189 | | - | |
3190 | | - | |
3191 | | - | |
3192 | | - | |
3193 | | - | |
3194 | | - | |
3195 | | - | |
3196 | | - | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
3197 | 3195 | | |
3198 | | - | |
3199 | | - | |
3200 | | - | |
3201 | | - | |
3202 | | - | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
3203 | 3201 | | |
3204 | | - | |
3205 | | - | |
3206 | | - | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
3207 | 3205 | | |
3208 | | - | |
3209 | | - | |
3210 | | - | |
3211 | | - | |
3212 | | - | |
3213 | | - | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
3214 | 3212 | | |
3215 | | - | |
3216 | | - | |
3217 | | - | |
3218 | | - | |
3219 | | - | |
3220 | | - | |
3221 | | - | |
3222 | | - | |
3223 | | - | |
3224 | | - | |
3225 | | - | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
3226 | 3224 | | |
3227 | | - | |
3228 | | - | |
| 3225 | + | |
| 3226 | + | |
3229 | 3227 | | |
3230 | | - | |
3231 | | - | |
3232 | | - | |
3233 | | - | |
3234 | | - | |
3235 | | - | |
3236 | | - | |
3237 | | - | |
3238 | | - | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
3239 | 3239 | | |
3240 | | - | |
3241 | | - | |
3242 | | - | |
3243 | | - | |
3244 | | - | |
3245 | | - | |
3246 | | - | |
3247 | | - | |
3248 | | - | |
3249 | | - | |
3250 | | - | |
3251 | | - | |
3252 | | - | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
3253 | 3243 | | |
3254 | | - | |
3255 | | - | |
3256 | | - | |
3257 | | - | |
3258 | | - | |
3259 | | - | |
3260 | | - | |
3261 | | - | |
3262 | | - | |
3263 | | - | |
3264 | | - | |
3265 | | - | |
3266 | | - | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
3267 | 3257 | | |
3268 | | - | |
3269 | | - | |
3270 | | - | |
3271 | | - | |
3272 | | - | |
3273 | | - | |
3274 | | - | |
3275 | | - | |
3276 | | - | |
3277 | | - | |
3278 | | - | |
3279 | | - | |
3280 | | - | |
3281 | | - | |
3282 | | - | |
3283 | | - | |
3284 | | - | |
3285 | | - | |
3286 | | - | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
3287 | 3262 | | |
3288 | 3263 | | |
3289 | | - | |
| 3264 | + | |
3290 | 3265 | | |
3291 | 3266 | | |
3292 | 3267 | | |
| |||
3314 | 3289 | | |
3315 | 3290 | | |
3316 | 3291 | | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
3317 | 3297 | | |
3318 | 3298 | | |
3319 | 3299 | | |
| |||
3388 | 3368 | | |
3389 | 3369 | | |
3390 | 3370 | | |
3391 | | - | |
3392 | | - | |
3393 | | - | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
3394 | 3375 | | |
3395 | 3376 | | |
| 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 | + | |
3396 | 3415 | | |
3397 | 3416 | | |
3398 | 3417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
231 | 248 | | |
232 | 249 | | |
233 | 250 | | |
| |||
0 commit comments