Repository: flutter
Issue:  Context null in  MaterialLocalizations.of(context) (package:flutter/src/material/material_localizations.dart:684)
Labels: framework,f: material design,a: internationalization,a: error message,P2,team-design,triaged-design

### Steps to reproduce

The   iPhone14pro(17.4.1 System version)   occasionally displays an abnormal  Tabbar
Not all iOS devices will show up
Android devices were not found to have this problem

```dart
static MaterialLocalizations of(BuildContext context) {
    assert(debugCheckHasMaterialLocalizations(context));
    return Localizations.of<MaterialLocalizations>(context, MaterialLocalizations)!;
  }
```

This API returns null

Two similar issues premised on this
https://github.com/flutter/flutter/issues/152979
https://github.com/flutter/flutter/issues/101292

Our solution is to let the user reinstall the APP, which is likely to avoid repetition


Full stacktrace

```
# Null check operator used on a null value

#0 MaterialLocalizations.of (package:flutter/src/material/material_localizations.dart:684)
#1 _TabBarState.build (package:ylcstudent/kffa/widgets/custom_tabbar.dart:1323)
#2 StatefulElement.build (package:flutter/src/widgets/framework.dart:5583)
#3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5471)
#4 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634)
#5 Element.rebuild (package:flutter/src/widgets/framework.dart:5187)
#6 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657)
#7 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#8 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743)
#9 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496)
#11 Element.rebuild (package:flutter/src/widgets/framework.dart:5187)
#12 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547)
#13 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#14 Element.updateChildren (package:flutter/src/widgets/framework.dart:3964)
#15 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896)
#16 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#17 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496)
#18 Element.rebuild (package:flutter/src/widgets/framework.dart:5187)
#19 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800)
#20 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#21 Element.updateChildren (package:flutter/src/widgets/framework.dart:3964)
#22 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896)
#23 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#24 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743)
#25 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#26 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743)
#27 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496)
#29 Element.rebuild (package:flutter/src/widgets/framework.dart:5187)
#30 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547)
#31 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#32 Element.updateChildren (package:flutter/src/widgets/framework.dart:3964)
#33 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896)
#34 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#35 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743)
#36 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#37 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743)
#38 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#39 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496)
#40 Element.rebuild (package:flutter/src/widgets/framework.dart:5187)
#41 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547)
#42 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#43 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496)
#44 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634)
#45 Element.rebuild (package:flutter/src/widgets/framework.dart:5187)
#46 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657)
#47 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#48 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743)
#49 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#50 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743)
#51 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#52 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496)
#53 Element.rebuild (package:flutter/src/widgets/framework.dart:5187)
#54 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547)
#55 Element.updateChild (package:flutter/src/widgets/framework.dart:3815)
#56 _SliverPersistentHeaderElement._build.<anonymous closure> (package:flutter/src/widgets/sliver_persistent_header.dart:298)
#57 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2835)
#58 _SliverPersistentHeaderElement._build (package:flutter/src/widgets/sliver_persistent_header.dart:296)
#59 _RenderSliverPersistentHeaderForWidgetsMixin.updateChild (package:flutter/src/widgets/sliver_persistent_header.dart:382)
#60 RenderSliverPersistentHeader.layoutChild.<anonymous closure> (package:flutter/src/rendering/sliver_persistent_header.dart:223)
#61 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2657)
#62 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1071)
#63 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2657)
#64 RenderSliverPersistentHeader.layoutChild (package:flutter/src/rendering/sliver_persistent_header.dart:221)
#65 RenderSliverPinnedPersistentHeader.performLayout (package:flutter/src/rendering/sliver_persistent_header.dart:417)
#66 RenderObject.layout (package:flutter/src/rendering/object.dart:2546)
#67 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:601)
#68 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1554)
#69 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1463)
#70 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2385)
#71 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1025)
#72 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1038)
#73 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:591)
#74 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:986)
#75 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457)
#76 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325)
#77 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255)
#78 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113)
#79 _rootRun (dart:async/zone.dart:1399)
#80 _CustomZone.run (dart:async/zone.dart:1301)
#81 _CustomZone.runGuarded (dart:async/zone.dart:1209)
#82 _invoke (dart:ui/hooks.dart:314)
#83 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383)
#84 _drawFrame (dart:ui/hooks.dart:283)
```

### Expected results

The   iPhone14pro(17.4.1 System version)   occasionally displays an normal  Tabbar

### Actual results

The   iPhone14pro(17.4.1 System version)   occasionally displays an abnormal  Tabbar



### Code sample

<details open><summary>Code sample</summary>

```dart
class HomeApp extends StatelessWidget {
  const HomeApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: const [
        // 这行是关键
        RefreshLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('zh', 'CN'),
      ],
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      child: Scaffold(
        appBar: AppBar(
          title: Text('Test'),
          bottom:
              TabBar(tabs: ['tab1', 'tab2'].map((e) => Tab(text: e)).toList()),
        ),
        body: Column(
          children: [TextField()],
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.1.1 23B81 darwin-arm64, locale
    zh-Hans-CN)
    • Flutter version 3.16.5 on channel stable at
      /Users/edy/Documents/3.16.5/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (9 months ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/edy/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/edy/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.96.0

[✓] Connected device (3 available)
    • iPhoneXs (mobile) • 00008020-000270543A83002E • ios            • iOS 17.2.1 21C66
    • macOS (desktop)   • macos                     • darwin-arm64   • macOS 14.1.1 23B81
      darwin-arm64
    • Chrome (web)      • chrome                    • web-javascript • Google Chrome
      128.0.6613.138

[✓] Network resources
    • All expected network resources are available.
```

</details>