我有以下小部件:
class OutsiderButton extends StatelessWidget {
final Function onPressed;
final Icon icon;
final OutsiderButtonPosition position;
OutsiderButton({this.onPressed, @required this.icon, this.position});
@override
Widget build(BuildContext context) {
return new Stack(fit: StackFit.loose, alignment: Alignment.center, children: [
new CustomPaint(
painter: new _OutsiderShape(position: position),
size: Size(60.0, 60.0),
isComplex: false,
),
OutlineButton(
borderSide: BorderSide(width: 1.0, color: Colors.white),
color: AppThemeColors.accentColor,
shape: new CircleBorder(),
child: new Padding(
padding: const EdgeInsets.all(6.0),
child: icon,
),
onPressed: onPressed,
)
]);
}
}
Run Code Online (Sandbox Code Playgroud)
它用于CustomPainter绘制背景。我需要它CustomPainter来绘制阴影,但是每次单击小部件时,阴影都会重新绘制并变得越来越强。这是CustomPainter:
class _OutsiderShape extends …Run Code Online (Sandbox Code Playgroud) 在Android中,当一个Activity被销毁时,我应该删除所有的侦听器
ref.addAuthStateListener(listener);
ref.addListenerForSingleValueEvent(listener);
ref.addChildEventListener(listener);
ref.addValueEventListener(listener);
Run Code Online (Sandbox Code Playgroud)
使用ref.removeEventListener(listener)或它们会被自动销毁?
我知道因为FirebaseRecyclerAdapter我们可以cleanup()用来做这项工作.除了监听器和适配器之外还有其他需要清理的对象吗?