Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Flutter Inappwebview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
Flutter Inappwebview
Commits
a9bcbe1f
Commit
a9bcbe1f
authored
Dec 07, 2018
by
Joao Paulo Marquesini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing a problem in safari webview and adding tabs to examples
parent
8b5a6347
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
256 additions
and
439 deletions
+256
-439
.gitignore
.gitignore
+1
-0
example/lib/chrome_safari_example.screen.dart
example/lib/chrome_safari_example.screen.dart
+46
-0
example/lib/inline_example.screen.dart
example/lib/inline_example.screen.dart
+95
-0
example/lib/main.dart
example/lib/main.dart
+24
-438
example/lib/webview_example.screen.dart
example/lib/webview_example.screen.dart
+88
-0
ios/Classes/InAppWebView.swift
ios/Classes/InAppWebView.swift
+1
-1
lib/flutter_inappbrowser.dart
lib/flutter_inappbrowser.dart
+1
-0
No files found.
.gitignore
View file @
a9bcbe1f
.DS_Store
.dart_tool/
.vscode/
.packages
.pub/
pubspec.lock
...
...
example/lib/chrome_safari_example.screen.dart
0 → 100644
View file @
a9bcbe1f
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
class
MyChromeSafariBrowser
extends
ChromeSafariBrowser
{
MyChromeSafariBrowser
(
browserFallback
)
:
super
(
browserFallback
);
@override
void
onOpened
()
{
print
(
"ChromeSafari browser opened"
);
}
@override
void
onLoaded
()
{
print
(
"ChromeSafari browser loaded"
);
}
@override
void
onClosed
()
{
print
(
"ChromeSafari browser closed"
);
}
}
class
ChromeSafariExampleScreen
extends
StatefulWidget
{
final
ChromeSafariBrowser
browser
=
new
MyChromeSafariBrowser
(
new
InAppBrowser
());
@override
_ChromeSafariExampleScreenState
createState
()
=>
new
_ChromeSafariExampleScreenState
();
}
class
_ChromeSafariExampleScreenState
extends
State
<
ChromeSafariExampleScreen
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Center
(
child:
new
RaisedButton
(
onPressed:
()
async
{
await
widget
.
browser
.
open
(
"https://flutter.io/"
);
},
child:
Text
(
"Open Chrome Safari Browser"
)),
);
}
}
example/lib/inline_example.screen.dart
0 → 100644
View file @
a9bcbe1f
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
class
InlineExampleScreen
extends
StatefulWidget
{
@override
_InlineExampleScreenState
createState
()
=>
new
_InlineExampleScreenState
();
}
class
_InlineExampleScreenState
extends
State
<
InlineExampleScreen
>
{
InAppWebViewController
webView
;
String
url
=
""
;
double
progress
=
0
;
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
child:
Column
(
children:
<
Widget
>[
Container
(
padding:
EdgeInsets
.
all
(
20.0
),
child:
Text
(
"CURRENT URL
\n
${(url.length > 50) ? url.substring(0, 50) + "..." : url}
"
),
),
Container
(
padding:
EdgeInsets
.
all
(
10.0
),
child:
progress
<
1.0
?
LinearProgressIndicator
(
value:
progress
)
:
null
),
Expanded
(
child:
Container
(
margin:
const
EdgeInsets
.
all
(
10.0
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
Colors
.
blueAccent
)),
child:
InAppWebView
(
initialUrl:
"https://flutter.io/"
,
initialHeaders:
{},
initialOptions:
{},
onWebViewCreated:
(
InAppWebViewController
controller
)
{
webView
=
controller
;
},
onLoadStart:
(
InAppWebViewController
controller
,
String
url
)
{
print
(
"started
$url
"
);
setState
(()
{
this
.
url
=
url
;
});
},
onProgressChanged:
(
InAppWebViewController
controller
,
int
progress
)
{
setState
(()
{
this
.
progress
=
progress
/
100
;
});
},
),
),
),
ButtonBar
(
alignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
RaisedButton
(
child:
Icon
(
Icons
.
arrow_back
),
onPressed:
()
{
if
(
webView
!=
null
)
{
webView
.
goBack
();
}
},
),
RaisedButton
(
child:
Icon
(
Icons
.
arrow_forward
),
onPressed:
()
{
if
(
webView
!=
null
)
{
webView
.
goForward
();
}
},
),
RaisedButton
(
child:
Icon
(
Icons
.
refresh
),
onPressed:
()
{
if
(
webView
!=
null
)
{
webView
.
reload
();
}
},
),
],
),
]));
}
}
example/lib/main.dart
View file @
a9bcbe1f
This diff is collapsed.
Click to expand it.
example/lib/webview_example.screen.dart
0 → 100644
View file @
a9bcbe1f
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
class
MyInappBrowser
extends
InAppBrowser
{
@override
Future
onBrowserCreated
()
async
{
print
(
"
\n\n
Browser Ready!
\n\n
"
);
}
@override
Future
onLoadStart
(
String
url
)
async
{
print
(
"
\n\n
Started
$url
\n\n
"
);
}
@override
Future
onLoadStop
(
String
url
)
async
{
print
(
"
\n\n
Stopped
$url
\n\n
"
);
}
@override
Future
onScrollChanged
(
int
x
,
int
y
)
async
{
print
(
"Scrolled: x:
$x
y:
$y
"
);
}
@override
void
onLoadError
(
String
url
,
int
code
,
String
message
)
{
print
(
"Can't load
$url
.. Error:
$message
"
);
}
@override
void
onProgressChanged
(
int
progress
)
{
print
(
"Progress:
$progress
"
);
}
@override
void
onExit
()
{
print
(
"
\n\n
Browser closed!
\n\n
"
);
}
@override
void
shouldOverrideUrlLoading
(
String
url
)
{
print
(
"
\n\n
override
$url
\n\n
"
);
this
.
webViewController
.
loadUrl
(
url
);
}
@override
void
onLoadResource
(
WebResourceResponse
response
,
WebResourceRequest
request
)
{
print
(
"Started at: "
+
response
.
startTime
.
toString
()
+
"ms ---> duration: "
+
response
.
duration
.
toString
()
+
"ms "
+
response
.
url
);
}
@override
void
onConsoleMessage
(
ConsoleMessage
consoleMessage
)
{
print
(
consoleMessage
.
message
);
}
}
class
WebviewExampleScreen
extends
StatefulWidget
{
final
InAppBrowser
browser
=
new
InAppBrowser
();
@override
_WebviewExampleScreenState
createState
()
=>
new
_WebviewExampleScreenState
();
}
class
_WebviewExampleScreenState
extends
State
<
WebviewExampleScreen
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Center
(
child:
new
RaisedButton
(
onPressed:
()
{
widget
.
browser
.
open
(
url:
"https://flutter.io/"
);
},
child:
Text
(
"Open Webview Browser"
)),
);
}
}
ios/Classes/InAppWebView.swift
View file @
a9bcbe1f
...
...
@@ -26,7 +26,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
scrollView
.
delegate
=
self
}
required
init
(
coder
aDecoder
:
NSCoder
)
{
required
public
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
!
}
...
...
lib/flutter_inappbrowser.dart
View file @
a9bcbe1f
...
...
@@ -487,6 +487,7 @@ class ChromeSafariBrowser {
args
.
putIfAbsent
(
'headers'
,
()
=>
headersFallback
);
args
.
putIfAbsent
(
'options'
,
()
=>
options
);
args
.
putIfAbsent
(
'optionsFallback'
,
()
=>
optionsFallback
);
args
.
putIfAbsent
(
'isData'
,
()
=>
false
);
args
.
putIfAbsent
(
'useChromeSafariBrowser'
,
()
=>
true
);
await
_ChannelManager
.
channel
.
invokeMethod
(
'open'
,
args
);
this
.
_isOpened
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment