photo_view
photo_view copied to clipboard
customChild is unable to receive touch event
In the following simple example I am unable to press the left or right button:
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
final List<String> buttonNames = ['left', 'middle', 'right'];
@override
Widget build(BuildContext context) {
return PhotoView.customChild(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: buttonNames
.map((n) => Container(
width: 100,
child: RaisedButton(
child: Text(n),
onPressed: () {
print('pressed $n');
}),
))
.toList(),
),
childSize: Size(1000, 200),
);
}
}
The whole child of PhotoView.customChild
will be wrapped in a GestureDetector. This bug is related to GestureArenaManager
prioritizing the gestures in the built inGestureDetector
. We should use RawGestureDetector
.
So why doesn't this happen with the middle button? Seemed more like a transform issue to me.
Any update on this?
@jvictorsoto Unfortunately I have been unable to apply so much time working on PhotoView in the last month. So... nope, not much progress on this. But every bug
tagged issue is a priority right now, including this very one.
After some investigation, I've reached into https://github.com/flutter/flutter/issues/27587 and https://github.com/flutter/flutter/issues/25702
Hence it seems like a Flutter issue.
It seems like will be solved at https://github.com/flutter/flutter/pull/32192
Any idea if this issue on flutter has been solved? I'm using Channel beta, v1.6.3, and still can't tap on widgets inside the custom child
It seems like it wasn't related to that bugfix. This was merged into flutter master on Jun 1. But even now on the master channel the same issue keeps happening. Tested it with flutter v1.10.15-pre.23.
No, it was not. But flutter/flutter#27587 and flutter/flutter#25702 are still open. I will try some workaround, but since this is a framework bug, I don't think we can do much here.
I don't really think this is a framework bug. For example
SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
controller: verticalScrollController,
child: child, // must be big enough to be scrollable
),
)
This also hides Buttons which are not visible but you can scroll to them and click them. I guess one would need to adapt whatever is done in the SingleChildScrollViews and adapt it to this library.
This also hides Buttons which are not visible but you can scroll to them and click them. I guess one would need to adapt whatever is done in the SingleChildScrollViews and adapt it to this library.
That is because scroll views work on a totally different way for a very different purpose. Scrolls uses the sliver protocol, that are basically made for that: scrolls in one axis.
Photo view uses simple matrix transformations, that happens after layout.
Since there is no intention for the framework team to fix transformed gesture detectors, here is a tip for anyone facing this problem: try to wrap photo view with a gesture detector externally.
Since there is no intention for the framework team to fix transformed gesture detectors, here is a tip for anyone facing this problem: try to wrap photo view with a gesture detector externally.
what do you mean externally? can you give example?