DEVELOPER GUIDE
Integration with WhiteLabel
Flutter integration
3 min
accessing link using webview use webview flutter https //github com/flutter/packages/tree/main/packages/webview flutter/webview flutter as webview component to load klavi link for authorization and data sharing according to the original official openfinance article( https //openfinancebrasil atlassian net/wiki/spaces/draftof/pages/7995738/redirecionamento+app to app https //openfinancebrasil atlassian net/wiki/spaces/draftof/pages/7995738/redirecionamento+app to app ), we assume by default that all institutions implement deeplinks, so we only deal with deep links and no longer deal with android 'intent //' or custom url scheme import 'package\ flutter/material dart'; import 'package\ go router/go router dart'; import 'package\ url launcher/url launcher dart'; import 'package\ webview flutter/webview flutter dart'; import 'package\ webview flutter wkwebview/webview flutter wkwebview\ dart'; class webpage extends statefulwidget { const webpage({super key}); @override state\<webpage> createstate() => webpagestate(); } class webpagestate extends state\<webpage> { late final webviewcontroller webviewcontroller; static const urlwhitelist = \[ 'https //conecte sandbox klavi ai', 'https //conecte testing klavi ai', 'https //conecte klavi ai', 'https //www google com/recaptcha', 'https //recaptcha google com/recaptcha', ]; bool isinwhitelistfn(string url) { return urlwhitelist any((element) => url startswith(element)); } @override void initstate() { super initstate(); late final platformwebviewcontrollercreationparams params; if (webviewplatform instance is webkitwebviewplatform) { params = webkitwebviewcontrollercreationparams( allowsinlinemediaplayback true, mediatypesrequiringuseraction const \<playbackmediatypes>{}, ); } else { params = const platformwebviewcontrollercreationparams(); } webviewcontroller = webviewcontroller fromplatformcreationparams(params); webviewcontroller setjavascriptmode(javascriptmode unrestricted) setnavigationdelegate(navigationdelegate( onnavigationrequest (navigationrequest request) async { if (request url == 'about\ blank') { return navigationdecision prevent; } try { uri requesturi = uri parse(request url); if (isinwhitelistfn(requesturi tostring())) { return navigationdecision navigate; } launchurl(requesturi, mode launchmode externalapplication); return navigationdecision prevent; } catch (e) { debugprint('e $e'); return navigationdecision prevent; } })); } @override widget build(buildcontext context) { final string url = gorouterstate of(context) extra! as string; webviewcontroller loadrequest(uri parse(url)); return scaffold( appbar appbar( title const text('web'), ), body column( mainaxisalignment mainaxisalignment start, crossaxisalignment crossaxisalignment center, children \[ expanded(child webviewwidget(controller webviewcontroller)), ], )); } } if you were a klavi customer before 22/11/2024, you may be able to use the links according to the old nomenclature, then, the urlwhitelist response may look like 'https //open sandbox klavi ai', 'https //open testing klavi ai', 'https //open klavi ai', it is necessary to set up a whitelist containing the domain name of klavi otherwise the klavi link will be opened with the system browser github github klaviai/klavilinkdemoflutter https //github com/klaviai/klavilinkdemoflutter demo app download klavi link demo flutter https //www pgyer com/whnxu8