- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用 CupertinoApp 小部件来包装我的应用程序,同时尝试在其中使用 Material TextFormField 小部件。
例如,当我触发文本选择模式(双击文本字段)时,出现以下错误(因为它试图打开一个需要 Material 本地化的叠加小部件):
未找到 MaterialLocalizations。OverlayEntry 小部件需要由 Localizations 小部件祖先提供的 MaterialLocalizations。
本地化用于生成 Material 库使用的许多不同消息、标签和缩写。
要引入 MaterialLocalizations,请在您的应用程序的根部使用 MaterialApp 以:自动包含它们,或添加带有 MaterialLocalizations 委托(delegate)的 Localization 小部件。
问题是我不能使用 MaterialApp,因为我需要使用 Cupertino 风格的导航(CupertinoTabBar/CupertinoTabView 中的嵌套导航器),所以我需要使用 Localization 小部件方法。
但是下面的代码并没有解决问题:
void main() {
runApp(
Localizations(
child: CupertinoApp(
debugShowCheckedModeBanner: false,
home: App(), // <-- Main Screen, a Cupertino Tab Scaffold with 3 CupertinoTabViews
),
locale: Locale('en', 'US'),
delegates: <LocalizationsDelegate>[
// I assumed these were sufficient, but the runtime exception still persist.
DefaultMaterialLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
),
);
}
那么我的问题是,执行此操作的正确方法是什么,是否不能在 CupertinoApp 中使用 Material 小部件?
I/flutter ( 7631): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 7631): The following assertion was thrown building
I/flutter ( 7631): _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#1e5c6](dirty, dependencies:
I/flutter ( 7631): [_LocalizationsScope-[GlobalKey#d1cfa]], state: _OverlayEntryState#ba2a3):
I/flutter ( 7631): No MaterialLocalizations found.
I/flutter ( 7631): _OverlayEntry widgets require MaterialLocalizations to be provided by a Localizations widget
I/flutter ( 7631): ancestor.
I/flutter ( 7631): Localizations are used to generate many different messages, labels,and abbreviations which are used
I/flutter ( 7631): by the material library.
I/flutter ( 7631): To introduce a MaterialLocalizations, either use a MaterialApp at the root of your application to
I/flutter ( 7631): include them automatically, or add a Localization widget with a MaterialLocalizations delegate.
I/flutter ( 7631): The specific widget that could not find a MaterialLocalizations ancestor was:
I/flutter ( 7631): _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#1e5c6]
I/flutter ( 7631): The ancestors of this widget were:
I/flutter ( 7631): Stack(alignment: AlignmentDirectional.topStart, fit: expand, overflow: clip)
I/flutter ( 7631): _Theatre
I/flutter ( 7631): Overlay-[LabeledGlobalKey<OverlayState>#362c7]
I/flutter ( 7631): _FocusScopeMarker
I/flutter ( 7631): Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null,
I/flutter ( 7631): hintOverrides: null)
I/flutter ( 7631): FocusScope
I/flutter ( 7631): AbsorbPointer(absorbing: false)
I/flutter ( 7631): Listener(listeners: [down, up, cancel], behavior: deferToChild)
I/flutter ( 7631): Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#2397a]
I/flutter ( 7631): DefaultTextStyle(inherit: false, color: Color(0xff000000), family: .SF Pro Text, size: 17.0,
I/flutter ( 7631): letterSpacing: -0.4, decoration: TextDecoration.none, softWrap: wrapping at box width, overflow:
I/flutter ( 7631): clip)
I/flutter ( 7631): Title(color: Color(0xff007aff))
I/flutter ( 7631): Directionality(textDirection: ltr)
I/flutter ( 7631): _LocalizationsScope-[GlobalKey#d1cfa]
I/flutter ( 7631): Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null,
I/flutter ( 7631): textDirection: ltr, hintOverrides: null)
I/flutter ( 7631): Localizations(locale: en_US, delegates: [DefaultCupertinoLocalizations.delegate(en_US),
I/flutter ( 7631): DefaultWidgetsLocalizations.delegate(en_US)])
I/flutter ( 7631): MediaQuery(MediaQueryData(size: Size(411.4, 683.4), devicePixelRatio: 2.6, textScaleFactor: 1.0,
I/flutter ( 7631): platformBrightness: Brightness.light, padding: EdgeInsets(0.0, 24.0, 0.0, 0.0), viewInsets:
I/flutter ( 7631): EdgeInsets.zero, alwaysUse24HourFormat: false, accessibleNavigation: falsedisableAnimations:
I/flutter ( 7631): falseinvertColors: falseboldText: false))
I/flutter ( 7631): WidgetsApp-[GlobalObjectKey _CupertinoAppState#5df27]
I/flutter ( 7631): IconTheme(IconThemeData#33904(color: Color(0xff007aff)))
I/flutter ( 7631): _InheritedCupertinoTheme
I/flutter ( 7631): CupertinoTheme
I/flutter ( 7631): ScrollConfiguration(behavior: _AlwaysCupertinoScrollBehavior)
I/flutter ( 7631): CupertinoApp
I/flutter ( 7631): Directionality(textDirection: ltr)
I/flutter ( 7631): _LocalizationsScope-[GlobalKey#dfb7d]
I/flutter ( 7631): Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null,
I/flutter ( 7631): textDirection: ltr, hintOverrides: null)
I/flutter ( 7631): Localizations(locale: en_US, delegates: [DefaultMaterialLocalizations.delegate(en_US),
I/flutter ( 7631): DefaultCupertinoLocalizations.delegate(en_US), DefaultWidgetsLocalizations.delegate(en_US)])
I/flutter ( 7631): _InheritedModel<AppModel>
I/flutter ( 7631): AnimatedBuilder(animation: Instance of 'AppModel')
I/flutter ( 7631): ScopedModel<AppModel>
I/flutter ( 7631): [root]
I/flutter ( 7631):
I/flutter ( 7631): When the exception was thrown, this was the stack:
I/flutter ( 7631): #0 debugCheckHasMaterialLocalizations.<anonymous closure> (package:flutter/src/material/debug.dart:124:7)
I/flutter ( 7631): #1 debugCheckHasMaterialLocalizations (package:flutter/src/material/debug.dart:127:4)
I/flutter ( 7631): #2 _MaterialTextSelectionControls.buildToolbar (package:flutter/src/material/text_selection.dart:135:12)
// ....
最佳答案
您不应将 CupertinoApp
包装到 Localization
中。
CupertinoApp
包括插入它自己的 Localization
小部件,因此无论您在 CupertinoApp
上面添加什么,都会被覆盖。
相反,将您的委托(delegate)直接传递给 CupertinoApp
的 localizationsDelegates
:
CupertinoApp(
localizationsDelegates: [
DefaultMaterialLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
),
关于dart - 如何将 CupertinoApp 包装在 Localizations 小部件中,以便我可以在其中使用 Material 小部件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55916342/
正在尝试创建一个 python 包。似乎有效,但我收到警告。我的 setup.py 是: #! /usr/bin/env python from distutils.core import setup
我导入了一个数据类型 X ,定义为 data X a = X a 在本地,我定义了一个通用量化的数据类型,Y type Y = forall a. X a 现在我需要定义两个函数, toY 和 fro
我似乎无法让编译器让我包装 Tokio AsyncRead: use std::io::Result; use core::pin::Pin; use core::task::{Context, Po
我有两个函数“a”和“b”。当用户上传文件时,“b”被调用。 “b”重命名文件并返回新文件名。之后应该编辑该文件。像这样: def a(): edits file def b(): r
我使用 Entity Framework 作为我的 ORM,我的每个类都实现了一个接口(interface),该接口(interface)基本上表示表结构(每个字段一个只读属性)。这些接口(inter
有没有办法打开一个程序,通常会打开一个新的jframe,进入一个现有的jframe? 这里是解释,我下载了一个java游戏,其中一个是反射游戏,它在一个jframe中打开,框架内有一堆子面板,我想要做
我想要下面的布局 | AA BBBBBBB | 除非没有足够的空间,在这种情况下 | AA | | BBBBBBB | 在这种情况下,A 是复选框,B 是复选框旁边的 Text
我正在尝试以不同的方式包装我的网站,以便将背景分为 2 部分。灰色部分是主要背景,还有白色部分,它较小并包装主要内容。 基本上我想要this看起来像this . 我不太确定如何添加图像来创建阴影效果,
我正在使用 : 读取整数文件 int len = (int)(new File(file).length()); FileInputStream fis = new FileInputStream(f
我使用 maven 和 OpenJDK 1.8 打包了一个 JavaFX 应用程序我的 pom.xml 中的相关部分: maven-assembly-plugin
我正在使用两个不同的 ItemsControl 来生成一个按钮列表。
我有一个情况,有一个变量会很方便,to , 可以是 TimerOutput或 nothing .我有兴趣提供一个采用与 @timeit 相同参数的宏来自 TimerOutputs(例如 @timeit
我正在尝试包装一个名为 content 的 div与另一个具有不同背景的 div。 但是,当将“margin-top”与 content 一起使用时div,似乎包装 DIV 获得了边距顶部而不是 co
文档不清楚,它似乎允许包装 dll 和 csproj 以在 Asp.Net Core 5 应用程序中使用。它是否允许您在 .Net Core 5 网站中使用针对 .Net Framework 4.6
我被要求开发一个层,该层将充当通用总线,而不直接引用 NServiceBus。到目前为止,由于支持不引人注目的消息,这并不太难。除了现在,我被要求为 IHandleMessages 提供我们自己的定义
我正在尝试包装 getServersideProps使用身份验证处理程序函数,但不断收到此错误:TypeError: getServerSideProps is not a function我的包装看
我有一个项目,它在特定位置(不是/src/resources)包含资源(模板文件)。我希望在运行 package-bin 时将这些资源打包。 我看到了 package-options 和 packag
我正在寻找打印从一系列对象中绘制的 div。我可以通过使用下面的管道语法来实现这一点。 each i, key in faq if (key == 0) |
我在 Meteor.js“main.js - Server”中有这个方法。 Meteor.methods({ messageSent: function (message) { var a
我注意到,如果我的自定义Polymer 1.x元素的宽度比纸张输入元素上的验证错误消息的宽度窄,那么错误将超出自定义元素的右边界。参见下图: 有没有一种机制可以防止溢出,例如在到达自定义元素的边界时自
我是一名优秀的程序员,十分优秀!