触摸手势可以传递给同级小部件吗?

时间:2019-06-08 01:24:38

标签: flutter touch uigesturerecognizer gesture flutter-layout

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(
      body: Container(
        child: MaterialButton(
          height: 100,
          color: Colors.grey,
          child: Text("DSG"),
          onPressed: () {
            print("Drawer sent gesture");
          },
        ),
      ),
      drawer: Container(
        height: 300,
        decoration: BoxDecoration(
          color: Colors.yellow,
        ),
        child: Center(
          child: MaterialButton(
            height: 100,
            color: Colors.grey,
            child: Text("DKG"),
            onPressed: () {
              print("Drawer kept gesture");
            },
          ),
        ),
      ),
    );
  }
}

我知道IgnorePointer & AbsorbPointer小部件可用于将手势从父级传递到子级,反之亦然。但是如果我想传递给同级小部件,例如从抽屉到正文,该怎么办?

仅应将属于1个兄弟姐妹的第一个孩子的手势传递给另一个,例如,我要求打开抽屉后即可单击“ DSG”和“ DKG”,即手势应通过抽屉稀松布。

0 个答案:

没有答案