flutter_sticky_header
flutter_sticky_header copied to clipboard
localPosition in GestureDetector details is incorrect
The vertical offset of the localPosition for onTapDown, when a GestureDetector is used in the child sliver, is offset by the size of the header in the sticky header component. For example, I would expect the top right corner of the container to be (0, 0) but if the header is 40 pixels high the top right corner is actually (0, 40).
Here's a gif, illustrating the issue:

Here is a minimal reproduction case:
import 'package:flutter/material.dart';
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('EXAMPLE'),
),
body: CustomScrollView(
slivers: [
StickyHeaderExample(),
],
),
),
),
);
}
class StickyHeaderExample extends StatefulWidget {
@override
_StickyHeaderExampleState createState() => _StickyHeaderExampleState();
}
class _StickyHeaderExampleState extends State<StickyHeaderExample> {
Offset tapPosition;
@override
Widget build(BuildContext context) {
return SliverStickyHeader(
header: SizedBox(
height: 40,
child: Center(child: Text('Header')),
),
sliver: SliverList(
delegate: SliverChildListDelegate(
[
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: GestureDetector(
onTapDown: (details) {
setState(() {
tapPosition = details.localPosition;
});
},
child: Container(
height: 200,
color: Colors.lightBlue,
alignment: Alignment.center,
child: tapPosition != null
? Text(
'dy: ${tapPosition.dy}',
style: TextStyle(color: Colors.white),
)
: null,
),
),
)
],
),
),
);
}
}
What is the version you use? Is it the same with the latest one?