- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
当此构建涉及 2 个 FloatingActionButton 时,我第一次构建页面时收到异常。
但是,如果我注释掉 2 个 FloatingActionButton 之一,运行该应用程序并在稍后阶段取消注释并继续进行热重载,它会起作用。
以下代码实现了一个图像选择器,并让用户可以选择从图库或相机中进行选择。
有人可以看看这个并告诉我我做错了什么吗?
我已经突出显示了导致异常的代码部分。
代码如下:
class ProfilePage extends StatefulWidget {
ProfilePage(this.profileId);
final int profileId;
@override
_ProfilePageState createState() => new _ProfilePageState();
}
class _ProfilePageState extends State<ProfilePage> {
var _imageInfo;
@override
void initState() {
_imageInfo = mid.currentProfile['Photo'];
super.initState();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(Translations
.of(context)
.text(widget.profileId == -1 ? 'profiles_add' : 'profiles_edit')),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(null),
),
],
leading: new Container(),
),
body: _build_body(),
);
}
_build_body() {
var profileImage;
profileImage = new Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
new GestureDetector(
child: new Container(
child: new ProfilePicture(imageInfo: _imageInfo),
width: 100.0,
height: 100.0,
alignment: Alignment.center,
),
onTap: () {},
),
// ##################################
new FloatingActionButton(
onPressed: () {
getImage(ImageSource.camera);
},
tooltip: 'Take a Photo',
child: new Icon(Icons.camera_alt)
),
new FloatingActionButton(
onPressed: () {
getImage(ImageSource.gallery);
},
tooltip: 'Pick Image from gallery',
child: new Icon(Icons.photo_library)
),
// ##################################
],
),
);
return new Container(
child: new Column(
children: [profileImage],
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
),
);
}
Future<dynamic> getImage(ImageSource source) async {
var imageFile = await ImagePicker.pickImage(source: source);
if (imageFile != null) {
List<int> imageBytes = imageFile.readAsBytesSync();
String base64Image = base64.encode(imageBytes);
setState(() {
_imageInfo = "base64:" + base64Image;
});
}
}
}
异常(exception)情况:
I/flutter ( 9045): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 9045): The following assertion was thrown during a scheduler callback:
I/flutter ( 9045): There are multiple heroes that share the same tag within a subtree.
I/flutter ( 9045): Within each subtree for which heroes are to be animated (typically a PageRoute subtree), each Hero
I/flutter ( 9045): must have a unique non-null tag.
I/flutter ( 9045): In this case, multiple heroes had the following tag: <default FloatingActionButton tag>
I/flutter ( 9045): Here is the subtree for one of the offending heroes:
I/flutter ( 9045): # Hero(tag: <default FloatingActionButton tag>, state: _HeroState#5ea48)
I/flutter ( 9045): # └KeyedSubtree-[GlobalKey#d064f]
I/flutter ( 9045): # └RawMaterialButton(state: _RawMaterialButtonState#8f3c6)
I/flutter ( 9045): # └Semantics(container: true, properties: SemanticsProperties, label: null, value: null, hint: null, renderObject: RenderSemanticsAnnotations#d7c9b relayoutBoundary=up5 NEEDS-PAINT)
I/flutter ( 9045): # └ConstrainedBox(BoxConstraints(w=56.0, h=56.0), renderObject: RenderConstrainedBox#8437c relayoutBoundary=up6 NEEDS-PAINT)
I/flutter ( 9045): # └Material(type: button, elevation: 6.0, color: Color(0xff2196f3), textStyle.debugLabel: ((englishLike button).merge(whiteMountainView button)).copyWith, textStyle.inherit: false, textStyle.color: Color(0xffffffff), textStyle.family: Roboto, textStyle.size: 14.0, textStyle.weight: 500, textStyle.letterSpacing: 1.2, textStyle.baseline: alphabetic, textStyle.decoration: TextDecoration.none, shape: CircleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none)), state: _MaterialState#73b5e)
I/flutter ( 9045): # └_MaterialInterior(duration: 200ms, shape: CircleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none)), elevation: 6.0, color: Color(0xff2196f3), shadowColor: Color(0xff000000), state: _MaterialInteriorState#aa4b9(ticker inactive))
I/flutter ( 9045): # └PhysicalShape(clipper: ShapeBorderClipper, elevation: 6.0, color: Color(0xff2196f3), shadowColor: Color(0xff000000), renderObject: RenderPhysicalShape#0486d NEEDS-PAINT)
I/flutter ( 9045): # └_ShapeBorderPaint
I/flutter ( 9045): # └CustomPaint(renderObject: RenderCustomPaint#7e004 NEEDS-PAINT)
I/flutter ( 9045): # └NotificationListener<LayoutChangedNotification>
I/flutter ( 9045): # └_InkFeatures-[GlobalKey#f1e6b ink renderer](renderObject: _RenderInkFeatures#34dbd NEEDS-PAINT)
I/flutter ( 9045): # └AnimatedDefaultTextStyle(duration: 200ms, debugLabel: ((englishLike button).merge(whiteMountainView button)).copyWith, inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, letterSpacing: 1.2, baseline: alphabetic, decoration: TextDecoration.none, softWrap: wrapping at box width, overflow: clip, state: _AnimatedDefaultTextStyleState#c8a96(ticker inactive))
I/flutter ( 9045): # └DefaultTextStyle(debugLabel: ((englishLike button).merge(whiteMountainView button)).copyWith, inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, letterSpacing: 1.2, baseline: alphabetic, decoration: TextDecoration.none, softWrap: wrapping at box width, overflow: clip)
I/flutter ( 9045): # └InkWell(gestures: [tap], clipped to BoxShape.rectangle, state: _InkResponseState<InkResponse>#32f3c)
I/flutter ( 9045): # └GestureDetector
I/flutter ( 9045): # └RawGestureDetector(state: RawGestureDetectorState#d6211(gestures: [tap], behavior: opaque))
I/flutter ( 9045): # └_GestureSemantics(renderObject: RenderSemanticsGestureHandler#d616c NEEDS-PAINT)
I/flutter ( 9045): # └Listener(listeners: [down], behavior: opaque, renderObject: RenderPointerListener#8a585 NEEDS-PAINT)
I/flutter ( 9045): # └Builder
I/flutter ( 9045): # └IconTheme(IconThemeData#15fa8(color: Color(0xffffffff)))
I/flutter ( 9045): # └Container(padding: EdgeInsets.zero)
I/flutter ( 9045): # └Padding(padding: EdgeInsets.zero, renderObject: RenderPadding#45f72 NEEDS-PAINT)
I/flutter ( 9045): # └Center(alignment: center, widthFactor: 1.0, heightFactor: 1.0, renderObject: RenderPositionedBox#a4315 NEEDS-PAINT)
I/flutter ( 9045): # └SizedBox.expand(renderObject: RenderConstrainedBox#af3fc relayoutBoundary=up1 NEEDS-PAINT)
I/flutter ( 9045): # └Tooltip("Pick Image from gallery", vertical offset: 24.0, position: below, state: _TooltipState#36588(ticker inactive))
I/flutter ( 9045): # └GestureDetector
I/flutter ( 9045): # └RawGestureDetector(state: RawGestureDetectorState#6cd1d(gestures: [long press], behavior: opaque))
I/flutter ( 9045): # └Listener(listeners: [down], behavior: opaque, renderObject: RenderPointerListener#aae3f NEEDS-PAINT)
I/flutter ( 9045): # └Semantics(container: false, properties: SemanticsProperties, label: "Pick Image from gallery", value: null, hint: null, renderObject: RenderSemanticsAnnotations#5fa0a NEEDS-PAINT)
I/flutter ( 9045): # └Builder
I/flutter ( 9045): # └IconTheme(IconThemeData#15fa8(color: Color(0xffffffff)))
I/flutter ( 9045): # └Icon(IconData(U+0E413))
I/flutter ( 9045): # └Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null, renderObject: RenderSemanticsAnnotations#8a909 NEEDS-PAINT)
I/flutter ( 9045): # └ExcludeSemantics(excluding: true, renderObject: RenderExcludeSemantics#fc581 NEEDS-PAINT)
I/flutter ( 9045): # └SizedBox(width: 24.0, height: 24.0, renderObject: RenderConstrainedBox#f68c4 NEEDS-PAINT)
I/flutter ( 9045): # └Center(alignment: center, renderObject: RenderPositionedBox#c38ac NEEDS-PAINT)
I/flutter ( 9045): # └RichText(textDirection: ltr, softWrap: wrapping at box width, maxLines: unlimited, text: "", renderObject: RenderParagraph#8873e relayoutBoundary=up1 NEEDS-PAINT)
I/flutter ( 9045):
I/flutter ( 9045): When the exception was thrown, this was the stack:
I/flutter ( 9045): #0 Hero._allHeroesFor.visitor.<anonymous closure> (package:flutter/src/widgets/heroes.dart:130:13)
I/flutter ( 9045): #1 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:140:10)
I/flutter ( 9045): #2 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #3 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #4 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4625:14)
I/flutter ( 9045): #5 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #6 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4725:16)
I/flutter ( 9045): #7 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #8 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4625:14)
I/flutter ( 9045): #9 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #10 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4725:16)
I/flutter ( 9045): #11 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #12 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #13 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #14 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #15 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #16 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #17 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #18 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4725:16)
I/flutter ( 9045): #19 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #20 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #21 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #22 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #23 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #24 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #25 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #26 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4625:14)
I/flutter ( 9045): #27 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #28 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #29 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #30 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4625:14)
I/flutter ( 9045): #31 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #32 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #33 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #34 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #35 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #36 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #37 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #38 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #39 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #40 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #41 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #42 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #43 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #44 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3659:14)
I/flutter ( 9045): #45 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:144:15)
I/flutter ( 9045): #46 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4625:14)
I/flutter ( 9045): #47 Element.visitChildElements (package:flutter/src/widgets/framework.dart:2625:5)
I/flutter ( 9045): #48 Hero._allHeroesFor (package:flutter/src/widgets/heroes.dart:146:13)
I/flutter ( 9045): #49 HeroController._startHeroTransition (package:flutter/src/widgets/heroes.dart:511:51)
I/flutter ( 9045): #50 HeroController._maybeStartHeroTransition.<anonymous closure> (package:flutter/src/widgets/heroes.dart:492:9)
I/flutter ( 9045): #51 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 9045): #52 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:938:9)
I/flutter ( 9045): #53 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter ( 9045): #54 _invoke (dart:ui/hooks.dart:120:13)
I/flutter ( 9045): #55 _drawFrame (dart:ui/hooks.dart:109:3)
I/flutter ( 9045): ════════════════════════════════════════════════════════════════════════════════════════════════════
最佳答案
好的,我发现将 heroTag: null
添加到 FloatingActionButton
的属性中可以解决问题。
导致异常的代码部分现在如下并且似乎可以正常工作:
new FloatingActionButton(
onPressed: () {
getImage(ImageSource.camera);
},
tooltip: 'Take a Photo',
child: new Icon(Icons.camera_alt),
heroTag: null,
),
new FloatingActionButton(
onPressed: () {
getImage(ImageSource.gallery);
},
tooltip: 'Pick Image from gallery',
child: new Icon(Icons.photo_library),
heroTag: null,
),
关于exception - Flutter:有 2 个 FloatingActionButton 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49964192/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!