0

I am currently working on an app that displays crypto currency details. So, I somehow need to display candlestick charts of coins against USDT. I already tried a major of libraries provided by flutter community but none of them was suitable for me. So I though that the best way to do this is displaying trading view charts in my personal app. However, ı couldn't figure out how to do it.

I found a library that displays web content: webview_flutter: ^3.0.4

And ı found that TradingView provides charts for web: TradingView Chart Widget

However, I couldn't manage to combine those since I am not that experienced about web development.

I am currently using flutter package Interactive Chart. Since I can't update the last candlestick continuously. It seems like it's not the best solution.

Thanks for all replies. :)

After @Almis 's Answer I Emulator Screen Shot

It seems like something happens, but not in the supposed way. Anyway to fix this ?

Arjein
  • 25
  • 8

1 Answers1

2

The website provides the embedded code that you can load to your webview.

// Get the embedded code from website
String embeddedCode = '...';

WebView(
    initialUrl: '',
    javascriptMode: JavascriptMode.unrestricted,
    onWebViewCreated: (WebViewController controller) async {
        controller.loadUrl(Uri.dataFromString(
            embeddedCode,
            mimeType: 'text/html',
            encoding: Encoding.getByName('utf-8')).toString());
    },
)
Almis
  • 3,684
  • 2
  • 28
  • 58
  • First of all Thanks for the reply. I got an exception: PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null)) Updated the Packages, No such exception. Thanks for the reply – Arjein Dec 09 '22 at 00:56
  • 1
    @Arjein that error seems. to be caused by outdated packages, check this https://stackoverflow.com/questions/72880037/unhandled-exception-platformexceptionchannel-error-unable-to-establish-connec – Almis Dec 09 '22 at 00:59
  • @Arjein After reviewing your edit it seems that it cannot run the javascript, try adding `javascriptMode: JavascriptMode.unrestricted`, check my edit – Almis Dec 09 '22 at 01:12