Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have a questionnaire build with office forms and I want to present the form inside flutter app. So far so good, but when the user tries to tap on an input field from the form the page refreshes itself.
The only gestures that can be performed are scrolling and marking a radio button.
I spend a lot of time trying to figure out how to enable the other gestures but it seems that is no way.
I found a parameter gestureRecognizer from the docs but I cannot figure out how to pass the gestures and what kind of gestures are required.
Any help will be appreciated.
Thanks!
Here is some example code with google.com
class QuestionnaireScreen extends StatelessWidget {
final GlobalKey<ScaffoldState> _quizScaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
InAppWebViewController _webViewController;
return Scaffold(
key: _quizScaffoldKey,
appBar: AppBar(
title: Text('Questionnaire'),
body: Container(
child: InAppWebView(
initialUrl: 'https://google.com',
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
useShouldOverrideUrlLoading: false,
mediaPlaybackRequiresUserGesture: false,
android: AndroidInAppWebViewOptions(
useShouldInterceptRequest: true,
ios: IOSInAppWebViewOptions(
allowsInlineMediaPlayback: true,
// gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{}..add(Factory<OneSequenceGestureRecognizer>() => TapGestureRecognizer()), - this gives an error: The argument type 'TapGestureRecognizer Function<OneSequenceGestureRecognizer>()' can't be assigned to the parameter type 'Factory<OneSequenceGestureRecognizer>'
onWebViewCreated: (InAppWebViewController vc) {
_webViewController = vc;
UPDATE:
I managed to make it work but with webview_flutter plugin with WebController
Here is the code:
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class QuestionnaireScreen extends StatefulWidget {
@override
_QuestionnaireScreenState createState() => _QuestionnaireScreenState();
class _QuestionnaireScreenState extends State<QuestionnaireScreen> {
final GlobalKey<ScaffoldState> _quizScaffoldKey = GlobalKey<ScaffoldState>();
@override
void initState() {
super.initState();
@override
Widget build(BuildContext context) {
WebViewController _webViewController;
return Scaffold(
key: _quizScaffoldKey,
appBar: AppBar(
title: Text('Questionnaire'),
body: Container(
child: WebView(
initialUrl: '/url here/',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController vc) {
_webViewController = vc;
gestureRecognizers: [
new Factory<OneSequenceGestureRecognizer>(
() => new EagerGestureRecognizer(),
].toSet(),
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.