【发布时间】:2019-08-12 06:14:15
【问题描述】:
我正在尝试用 Flutter 做这种事情: https://storage.googleapis.com/spec-host-backup/mio-design%2Fassets%2F0B3T7oTWa3HiFcHBDaTlreHdVZGc%2Fitem-selection-selecting-items.mp4
var gestureTemp = GestureDetector(
onLongPress: (){
print('LONG PRESSED');
//CHANGE APPBAR
},
child: Padding(
padding: EdgeInsets.only(right:8),
child: Chip(
avatar: CircleAvatar(
backgroundColor: Colors.grey.shade800,
child: icon
),
label: Text(space.label, style: TextStyle(fontSize: 12, color:Colors.grey.shade800))
),
));
它检测到长按,但我不知道如何更改我的应用栏...
有什么想法吗?
编辑:这就是我所做的
var appBar1 = AppBar(...);
var appBar2 = AppBar(...);
var appBar = appBar1;
我的 appBar 显示在我的 Scaffold 中。
在我的 GestureDetector 上:
onLongPress: (){
print('LONG PRESSED');
setState(() {
appBar = appBar2;
});
},
【问题讨论】:
-
您在更改应用栏时遇到了哪一步?图标的动画,颜色?用新的应用栏替换?
-
对我来说最好的办法是改变整个应用栏,你认为有可能吗?
-
目前,我已经创建了两个 appBar 变量,第一个是我常用的 appbar,第二个是长按后的 appbar。当我长按时,我调用了一个 setState,在其中我用第二个更改了我的 appbar,但没有任何变化
-
很高兴看到该代码 sn-p。您的方法听起来不错,但它只会切换没有动画的应用栏吗?
-
当然,稍后我会看到动画。我已经编辑了我的帖子,够吗?