- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在 MaterialApp 的应用栏中创建带有图标的简单英雄动画时,英雄动画似乎不使用主题颜色,除非在图标本身中明确指定颜色。有人可以解释为什么未明确设置图标颜色时图标颜色在飞行过程中发生变化吗?英雄是否无法访问主题数据?还是使用其他颜色集?
例子:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: Hero(
tag: "mytag",
child: Material(
color: Colors.transparent,
child: IconButton(
icon: Icon(
Icons.menu,
// uncomment below line and the flying icon is white as expected...
// color: Theme.of(context).primaryIconTheme.color
),
onPressed: () {
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder:
(context, animation, secondaryAnimation) => SecondPage()
)
);
},
),
),
),
),
);
}
}
class SecondPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
actions: <Widget> [
Hero(
tag: "mytag",
child: Material(
color: Colors.transparent,
child: IconButton(
icon: Icon(
Icons.menu,
// uncomment below line and the reverse flying icon is white as expected...
// color: Theme.of(context).primaryIconTheme.color
),
onPressed: () {
Navigator.of(context).pop();
},
),
),
),
]
),
);
}
}
最佳答案
发生这种情况是因为 Hero
的飞行动画是 MaterialApp
上的 OverlayEntry
。因此,虽然使用的小部件相同(图标),但其位置不同。
问题是,在您的情况下,IconTheme.of(context)
根据该位置返回不同的值:
AppBar
的子项,IconTheme
被覆盖以处理 primaryColor
作为背景MaterialApp
上指定的默认主题。 所以在动画的时候,使用的IconTheme
不一样,导致了这个问题。
一个潜在的解决方案是修复该值以确保使用的 IconTheme
始终相同:
AppBar(
leading: Builder(
builder: (context) {
return Hero(
child: IconTheme(
data: Theme.of(context).primaryIconTheme,
child: Icon(Icons.whatshot),
),
);
},
),
);
关于Flutter Hero动画不用主题色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53815339/
我最近试图在 firebase fcm 中添加,但它没有工作,只是导致了几个错误,所以我将所有内容回滚到原始运行代码,但在此过程中升级了 flutter ...因为 v1.3.10 英雄不能包含其子层
Hero Search {{hero.name}}
在 Angular 教程中 https://angular.io/tutorial/toh-pt1#selector ,我不明白这句话:“CSS 元素选择器,‘app-heroes’,匹配在父组件模板
我被卡住了on the third step of the Angular tour of heroes tutorial ,上次我检查时,在 Angular 2 和 4 中,这个解决方案有效。从那以
我正在从 angular tutorial 学习 angular4 .下面是一个从服务函数中获取英雄的函数: @Injectable() export class HeroService {
已更新。 我正在关注 Angular2 教程 https://angular.io/docs/ts/latest/tutorial/toh-pt4.html 这里是从heres.component.t
本文整理了Java中heros.ZeroedFlowFunctions类的一些代码示例,展示了ZeroedFlowFunctions类的具体用法。这些代码示例主要来源于Github/Stackover
在这段代码中,文本没有垂直居中放置在 div 上。我不明白,因为我给了职位 50%。对于图像,我不能给出我想要的自定义高度吗? 在我的照片上,顶部的蓝线是导航栏,不要介意。
我的游戏是横向卷轴游戏,因此英雄具有恒定的速度,每次更新都会设置为他的速度。当我用几个“盒子”组成一个楼层时,英雄停在第一个结束和第二个开始的地方。它们大小相同且位于同一 y 轴上,为什么会发生这种情
我想使用Hero框架。我没有从他们的文档中得到任何 pod 命令。我用过“英雄” pods 。它有效,但在安装和下载 pod 后,当尝试打开项目时,它说 Xcode 9 does not suppor
我不知道为什么 justify-self 对我的 .hero-content 不起作用。 我试图让我的 .hero-content 水平和垂直居中,它水平居中但垂直它仍然位于顶部。不确定该怎么做。 .
我想知道是否可以得到一些帮助。 我正在尝试创建一个 HERO,在这里您可以看到我是如何将它与 和 标签一起编写的 https://www.screencast.com/t/COOZ3dCy9l 在这里
我已将一个全屏背景视频和一些介绍文字放入主页的一个部分。现在我想继续将内容添加到主页的下半部分,但有些东西完全搞砸了。你可以明白我的意思: 我在要添加为视频下方新部分的新内容周围画了一个红圈。由于某种
我在主图上放置了几个标题标签。当我调整浏览器大小时,文本叠加会上下移动。关于如何将文本固定在英雄图片中间有什么想法吗? html:
我编写了一个 Android 应用程序,它使用蓝牙从外部传感器获取数据。它在索尼爱立信 XPERIA 上运行良好,但在 HTC Hero 上运行良好(它可以找到外部设备,但无法从中获取任何数据)我想知
我的游戏有一个有 4 个座位的摩天轮。每个座位都有一个平台,英雄可以在上面休息。当座位处于上升轨道时,英雄平静地留在平台上。 但是,当座椅处于向下轨迹时,Hero 会向上/向下移动一点。 我已经尝试了
我正在尝试控制 GoPro Hero 3 摄像机。在网上找了个图书馆:https://github.com/r1pper/GoPro.Hero从我读到的内容来看,这是一个不错的图书馆。但是,当我尝试与
我有一个带有文本的按钮,当我按下按钮时,具有相同文本的文本小部件会添加到同一页面。 我想在它们之间添加类似 Hero 的动画。 我想我需要的是 SlideTransition,但我不知道如何从一个小部
我在 PageView 的一页中有一个图像。当我转到它时,我想将此图像动画到下一页,有点像在导航器页面转换中使用英雄动画时。任何想法如何实现? 最佳答案 为了实现类似于英雄动画的动画。基本上我们将实现
“英雄”一词是什么意思,为什么用它来命名网站/页面的“主要信息”? 具体来说,我想知道术语“英雄”或短语“英雄单位”是否是我设法错过的网页设计中使用的一些常见术语。 最佳答案 电影/电视 Prop 设
我是一名优秀的程序员,十分优秀!