Flutter报错:No MaterialLocalizations found.

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following assertion was thrown building AppBar(dirty, dependencies: [_LocalizationsScope-[GlobalKey#17f6b]], state: _AppBarState#a8384): No MaterialLocalizations found.

AppBar widgets require MaterialLocalizations to be provided by a Localizations widget ancestor. The material library uses Localizations to generate messages, labels, and abbreviations.

To introduce a MaterialLocalizations, either use a MaterialApp at the root of your application to include them automatically, or add a Localization widget with a MaterialLocalizations delegate.

APP风格选用的cupertino,在page中使用了Scaffold对appBar进行了设置,导致的该原因。 解决方法:将Scaffold替换为cupertino中的CupertinoPageScaffold就可以了。

你可能感兴趣的:(Flutter报错:No MaterialLocalizations found.)