Skip to content

Instantly share code, notes, and snippets.

@iskakaushik
Created April 5, 2019 15:22
Show Gist options
  • Save iskakaushik/ff49eb21274263f4b4fbbacd15750a6a to your computer and use it in GitHub Desktop.
Save iskakaushik/ff49eb21274263f4b4fbbacd15750a6a to your computer and use it in GitHub Desktop.
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() => runApp(MaterialApp(home: CrashingWebViewExample()));
class CrashingWebViewExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
final double maxHeight = MediaQuery.of(context).size.height * 0.7;
print("maxHeight: $maxHeight");
return SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
padding: const EdgeInsets.all(20),
color: Colors.redAccent,
child: const Text("My Red TextWidget")),
_createWebViewWidget(maxHeight),
Container(
padding: const EdgeInsets.all(20),
color: Colors.blue,
child: const Text("My Blue TextWidget")),
],
),
);
}
Widget _createWebViewWidget(double maxHeight) {
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = [
Factory<OneSequenceGestureRecognizer>(() => EagerGestureRecognizer()),
].toSet();
return SingleChildScrollView(
child: Container(
height: maxHeight,
child: WebView(
initialUrl: 'https://en.wikipedia.org/wiki/Cephalopod_size',
gestureRecognizers: gestureRecognizers,
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment