Open Mateis opened 3 years ago
Hi @Mateis VoiceOver doesn't even seem to focus on GestureDetectorr hence it won't recognize any gestures, Is that the same for you?
Yes, I have the same behaviour. It doesn't select.
Maybe a separate Semantic wrapping widget is needed (on the gesture detector or Center widget)?
Yes, the following code made it work as expected:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
scrollDown(){
print(' scroll down');
}
scrollUp(){
print(' scroll up');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child:
Semantics(
focusable: true,
onScrollDown: scrollDown,
onScrollUp: scrollUp,
child:
GestureDetector(
onVerticalDragEnd: (endDetails) {
double velocity = endDetails.primaryVelocity;
if (velocity < 0) {
print('GESTURE -- Swipe Up');
} else if (velocity > 0) {
print('GESTURE -- Swipe Down');
}
},
)
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Hence, I had to wrap the GestureWidget with a Semantics widget and set the focus, OnScrollDown and OnScrollUp parameters.
Semantics(
focusable: true,
onScrollDown: scrollDown,
onScrollUp: scrollUp,
Hi @Mateis
I think your right Semantics might be required, see https://github.com/flutter/flutter/issues/49285
Even tho it prints, events are not announced, Voiceover doesn't say anything when I can scroll. GestureDetector
uses Raw GestureDetector which has semantics https://api.flutter.dev/flutter/widgets/RawGestureDetector/semantics.html. Shouldn't it be sufficient?
I think Semantics shouldn't require unless it is universal to all gesture widgets, working as design but what about the announcement, it doesn't solve that
Hmm yeah makes sense if you put it like that. On Android it seems to work fine without extra Semantics Widget, so that's odd.
Hi @Mateis
I can confirm it works out Semantics
widget on Android. Yet no announcements tho
stable |
master |
---|---|
❌ | ❌ |
Check flutter doctor -v
outputs for each channel below
✅ : No Issue ❌: Issue reproduced
@Mateis Let's keep the issue for iOS as it requires an extra Semantics widget
For the announcements on both platforms, we can track in a new issue
cc: @chunhtai
@Mateis Adding the additional semantics node makes sense to me, the gesture recognizer only make it draggable, but not necessary scrollable. drag can be any custom action, but scrolling is a very specific term.
@chunhtai
Do you know why it doesn't require on Android? and how we can make it announce, Is that a bug in the first?
Steps to Reproduce
flutter create bug
.Replace the default child of Center() with a GestureDetector
Expected results: Without VoiceOver activated, the app registers scroll action with a one finger swipe. With VoicerOver activated, the app registers scroll actions with a three finger swipe.
Three finger swipe is how users with VoiceOver activated scroll.
Actual results: As expected, without VoiceOver accessibility turned on, the scrolling using (one finger) swipe works. Unexpected, with VoiceOver on, the GestureDetector widget does not register a swipe action and users are not able to scroll using a three finger swipe.