I've an application in which I need to open some Interactive HTML5 content pages in flutter_web_browser. The feature works fine, but now I've requirement of stopping devices from going to sleep on these pages. I already tried solution mentioned over here. But that only works for app and not when these content pages are visited.

Anyone has any idea of accomplishing that or some workaroud?

Remember if I try to render those pages via WebView, the behavior becomes unpridictable in several devices. And even for IOS most of the times it doesn't work.

Please note that I can't render that content in WebView, because that has lot of issues.

The code that opens these pages look like below:

Future<dynamic> getPlatformBrowserWidget(String url) async {
    if (Platform.isIOS)
      return FlutterWebBrowser.openWebPage(
        url: url,
        safariVCOptions: SafariViewControllerOptions(
          barCollapsingEnabled: true,
          preferredBarTintColor: Theme.of(context).primaryColor,
          preferredControlTintColor: Colors.white,
          dismissButtonStyle: SafariViewControllerDismissButtonStyle.close,
          modalPresentationCapturesStatusBarAppearance: false,
        ),
      );
    else
      return FlutterWebBrowser.openWebPage(
        url: url,
        customTabsOptions: CustomTabsOptions(
          colorScheme: CustomTabsColorScheme.dark,
          toolbarColor: Theme.of(context).primaryColor,
          secondaryToolbarColor: Theme.of(context).primaryColor,
          navigationBarColor: Colors.white,
          addDefaultShareMenuItem: false,
          instantAppsEnabled: true,
          showTitle: false,
          urlBarHidingEnabled: true,
        ),
      );
  }
0

There are 0 best solutions below