diff --git a/CHANGELOG.md b/CHANGELOG.md index d58b2224..aa0353bd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ - Merged "Android - Load client certificate from local storage" [#1241](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1241) (thanks to [akioyamamoto1977](https://github.com/akioyamamoto1977)) - Merged "fix Theme_AppCompat_Dialog_Alert not found" [#1262](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1262) (thanks to [mohenaxiba](https://github.com/mohenaxiba)) - Merged "Allow a cookie without a domain to be set on Android" [#1295](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1295) (thanks to [bagedevimo](https://github.com/bagedevimo)) +- Merged "Catch and ignore utf8 format exception in getFavicons()" [#1302](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1302) (thanks to [Doflatango](https://github.com/Doflatango)) +- Merged "Disable exporting activity definitions for Android" [#1313](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1313) (thanks to [daanporon](https://github.com/daanporon)) +- Merged "Add directoryIndex and documentRoot to InAppLocalhostServer option" [#1319](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1319) (thanks to [fa0311](https://github.com/fa0311)) ## 5.4.4+3 diff --git a/example/lib/main.dart b/example/lib/main.dart index 3d9154cc..4d14c4fb 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -11,7 +11,7 @@ import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart' // import 'package:path_provider/path_provider.dart'; // import 'package:permission_handler/permission_handler.dart'; -// InAppLocalhostServer localhostServer = new InAppLocalhostServer(); +// InAppLocalhostServer localhostServer = new InAppLocalhostServer(documentRoot: 'assets'); Future main() async { WidgetsFlutterBinding.ensureInitialized(); diff --git a/lib/src/in_app_localhost_server.dart b/lib/src/in_app_localhost_server.dart index 91acb5bf..08860973 100755 --- a/lib/src/in_app_localhost_server.dart +++ b/lib/src/in_app_localhost_server.dart @@ -6,7 +6,8 @@ import 'package:flutter/services.dart' show rootBundle; import 'mime_type_resolver.dart'; -///This class allows you to create a simple server on `http://localhost:[port]/` in order to be able to load your assets file on a server. The default [port] value is `8080`. +///This class allows you to create a simple server on `http://localhost:[port]/` in order to be able to load your assets file on a server. +///The default `port` value is `8080`. class InAppLocalhostServer { bool _started = false; HttpServer? _server; @@ -14,6 +15,11 @@ class InAppLocalhostServer { String _directoryIndex = 'index.html'; String _documentRoot = './'; + ///- [port] represents the port of the server. The default value is `8080`. + /// + ///- [directoryIndex] represents the index file to use. The default value is `index.html`. + /// + ///- [documentRoot] represents the document root path to serve. The default value is `./`. InAppLocalhostServer({ int port = 8080, String directoryIndex = 'index.html', @@ -26,7 +32,8 @@ class InAppLocalhostServer { ///Starts the server on `http://localhost:[port]/`. /// - ///**NOTE for iOS**: For the iOS Platform, you need to add the `NSAllowsLocalNetworking` key with `true` in the `Info.plist` file (See [ATS Configuration Basics](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW35)): + ///**NOTE for iOS**: For the iOS Platform, you need to add the `NSAllowsLocalNetworking` key with `true` in the `Info.plist` file + ///(See [ATS Configuration Basics](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW35)): ///```xml ///NSAppTransportSecurity /// @@ -55,6 +62,10 @@ class InAppLocalhostServer { var path = request.requestedUri.path; path = (path.startsWith('/')) ? path.substring(1) : path; path += (path.endsWith('/')) ? _directoryIndex : ''; + if (path == '') { + // if the path still empty, try to load the index file + path = _directoryIndex; + } path = _documentRoot + path; try {