created a swipe trigger widget, but the button behind it is not responding.

Hello.
I wanted to detect swipes and make screen transitions, so I created a custom widget called SwipeTrigger.

I then placed the SwipeTrigger in front of the Stack and a button behind it.

As a result, the SwipeTrigger responded, but the button did not.

"behavior: HitTestBehavior.translucent"

The above code should detect the button behind, but it did not work.

Thank you in advance.

The code is below ↓.

// Automatic FlutterFlow imports

import '/backend/backend.dart';

import '/backend/schema/structs/index.dart';

import '/backend/schema/enums/enums.dart';

import '/actions/actions.dart' as action_blocks;

import '/flutter_flow/flutter_flow_theme.dart';

import '/flutter_flow/flutter_flow_util.dart';

import '/custom_code/widgets/index.dart'; // Imports other custom widgets

import '/custom_code/actions/index.dart'; // Imports custom actions

import '/flutter_flow/custom_functions.dart'; // Imports custom functions

import 'package:flutter/material.dart';

// Begin custom widget code

// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

class SwipeTrigger extends StatefulWidget {

const SwipeTrigger({

Key? key,

this.width,

this.height,

this.action,

}) : super(key: key);

final double? width;

final double? height;

final Future<dynamic> Function()? action;

@override

SwipeTriggerState createState() => SwipeTriggerState();

}

class _SwipeTriggerState extends State<SwipeTrigger> {

@override

Widget build(BuildContext context) {

return GestureDetector(

behavior: HitTestBehavior.translucent,

onHorizontalDragEnd: (details) {

if (details.primaryVelocity != null && details.primaryVelocity! > 0) {

if (widget.action != null) {

widget.action!();

}

}

},

child: Container(

width: widget.width,

height: widget.height,

color: Colors.transparent,

),

);

}

}

1
4 replies