fluttercommunity / fluttercommunity/page_turn
PageTurn + Flutter WebView
- Dominant language
- Dart
- Stars
- 202
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
Hi guys. I'm trying to use your plugin with Flutter WebView to render an epub file. The problem is that it seems that the PageTurn plugin doesn't work as expected when using Flutter WebView. All the pages are blank when using them together. Below the example main.dart I'm running:
```dart
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:page_turn/page_turn.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@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}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
final _controller = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
body: PageTurn(
key: _controller,
backgroundColor: Colors.white,
showDragCutoff: false,
lastPage: Container(child: Center(child: Text('Last Page!'))),
children: [
for (var i = 0; i < 20; i++) WebViewWidget(),
],
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.search),
onPressed: () {
_controller.currentState.goToPage(2);
},
),
);
}
}
class WebViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final htmlExample = "
My First Heading
My first paragraph.
";return WebView(
initialUrl: Uri.dataFromString(
htmlExample,
mimeType: 'text/html',
encoding: Encoding.getByName('utf-8')
).toString(),
javascriptMode: JavascriptMode.unrestricted,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
);
}
}
````
And the pubspec.yaml:
```yaml
name: page_turn_webview
description: A new Flutter project.
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# Webview
webview_flutter: ^0.3.20+2
page_turn: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
uses-material-design: true
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the example in main.dart and the dependency versions in pubspec.yaml, then reproduce the blank pages with PageTurn and webview_flutter together. Inspect the PageTurn and WebView entry points involved in rendering the listed children; the issue is done when the WebView content renders correctly on the PageTurn pages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100