Flutter web view update

parent e0eb6f45
......@@ -43,5 +43,20 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.Rp_organic.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="external_files"
path="." />
</paths>
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:flutter_webview_pro/webview_flutter.dart';
import 'package:modal_progress_hud/modal_progress_hud.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
class MyApp extends StatefulWidget {
@override
_WebViewWebPageState createState() => _WebViewWebPageState();
}
class _WebViewWebPageState extends State<MyApp> {
WebViewController controller;
bool showSpinner = true;
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
toolbarHeight: 70,
backgroundColor: Colors.teal[800],
title: Container(
child: Image.asset('assets/images/orgicheck lolgo2.png',width:300,height:100),
home: WillPopScope(
onWillPop: ()async{
String url = await controller.currentUrl();
if(url == "https://test-flask-research.herokuapp.com/"){
return true;
}else{
controller.goBack();
return false;
}
},
child: Scaffold(
body:ModalProgressHUD(
inAsyncCall: showSpinner,
child: Container(
child: SafeArea (
child: WebView(
initialUrl: "https://test-flask-research.herokuapp.com/",
javascriptMode: JavascriptMode.unrestricted,
gestureNavigationEnabled: true,
geolocationEnabled: false,//support geolocation or not
onWebViewCreated: (WebViewController wc){
controller = wc;
},
onPageFinished: (finished){
setState(() {
showSpinner = false;
});
},
),
),
),
),
centerTitle: true,
),
body: Builder(builder: (BuildContext context) {
return WebView(
initialUrl: 'https://test-flask-research.herokuapp.com/',
javascriptMode: JavascriptMode.unrestricted,
onProgress: (int progress) {
print("WebView is loading (progress : $progress%)");
},
navigationDelegate: (NavigationRequest request) {
if (request.url.startsWith('https://test-flask-research.herokuapp.com/')) {
print('blocking navigation to $request}');
return NavigationDecision.prevent;
}
print('allowing navigation to $request');
return NavigationDecision.navigate;
},
onPageStarted: (String url) {
print('Page started loading: $url');
},
onPageFinished: (String url) {
print('Page finished loading: $url');
},
gestureNavigationEnabled: true,
geolocationEnabled: false,//support geolocation or not
);
}),
),
);
}
}
\ No newline at end of file
}
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
......@@ -49,7 +56,14 @@ packages:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.0.3"
equatable:
dependency: transitive
description:
name: equatable
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.6"
fake_async:
dependency: transitive
description:
......@@ -62,6 +76,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_application_id:
dependency: "direct dev"
description:
name: flutter_application_id
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
......@@ -88,6 +109,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
modal_progress_hud:
dependency: "direct main"
description:
name: modal_progress_hud
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
path:
dependency: transitive
description:
......@@ -163,6 +191,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.7"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
......@@ -30,14 +30,25 @@ dependencies:
cupertino_icons: ^1.0.0
webview_flutter: ^1.0.0
flutter_webview_pro: ^1.0.0
modal_progress_hud: ^0.1.3
dev_dependencies:
flutter_application_id: "^1.0.0"
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
flutter_application_id:
android:
id: "com.example.Rp_organic"
name: "Rp_organic"
ios:
id: "com.example.Rp_organic"
name: "Rp_organic"
# The following section is specific to Flutter.
flutter:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment