Flutter AbsorbPointer 与 IgnorePointer的区别

移动开发 作者: 2024-08-25 00:05:01
AbsorbPointer AbsorbPointer是一种禁止用户输入的控件,比如按钮的点击、输入框的输入、ListView的滚动等,你可能说将按钮的 设置为null,一样也可以实现,是的,但Abs
AbsorbPointer(
  child: Row(
    children: <Widget>[
      RaisedButton(onPressed: (){},),RaisedButton(onPressed: (){},],)
AbsorbPointer(
  absorbing: false,...
)
IgnorePointer(
  child: Row(
    children: <Widget>[
      RaisedButton(onPressed: (){},)
return Container(
      height: 200,width: 200,child: Stack(
        alignment: Alignment.center,children: <Widget>[
          Listener(
            onPointerDown: (v) {
              print('click red');
            },child: Container(
              color: Colors.red,Listener(
            onPointerDown: (v) {
              print('click red');
            },child: Container(
              color: Colors.blue,width: 100,height: 100,);
flutter: click blue
flutter: click red
return Container(
  height: 200,child: Stack(
    alignment: Alignment.center,children: <Widget>[
      Listener(
        onPointerDown: (v) {
          print('click red');
        },child: Container(
          color: Colors.red,Listener(
        onPointerDown: (v) {
          print('click blue self');
        },child: AbsorbPointer(
          child: Listener(
            onPointerDown: (v) {
              print('click blue child');
            },);
flutter: click blue self
flutter: click red
原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_68095.html