Planning and troubleshooting Flutter app development with Flutter WebView and the steem.js SDKsteemCreated with Sketch.

in #blog2 years ago (edited)

About 2 years ago, I tried to develop steemdart_ecc for DART. However, due to personal reasons, the project was discontinued. Nevertheless, I implemented the following features: Steem account registration, balance inquiry, Steem/SteemDollar transfer, Steem power-up/power-down, account history inquiry, and post upload.

However, I have no desire to start this project again. Instead, I want to develop a community flutter app instead of a wallet, this time using the flutter webview and steem.js SDK.

Flutter Webview + Steem.js SDK

I started this by using the webview_flutter package. I then created a WebViewController controller and hid the webview from view.

// Load the index.html file and javascipt through the WebViewController.
final WebViewController controller = useMemoized(
      () => WebViewController()
        ..setJavaScriptMode(JavaScriptMode.unrestricted)
        ..loadFlutterAsset('assets/index.html'),
    );
// Set the height to 0 to make it invisible to the screen.
SizedBox(
    height: 0,
    child: WebViewWidget(controller: controller),
),

Now, when we request a write, we call the steem.js through the webview.

final results = await controller.runJavaScriptReturningResult("""
    window.steem.broadcast.commentAsync(
      '$postingKey',
      '$parent_author',
      '$parent_permlink',
      '$username',
      '$permlink',
      '$title',
      '$body',
      {
        "tags": ['test'],
        "app": 'steemlife/0.0.1',
      },
    );""");

However, the problem is that the commentAsync function works asynchronously, so we don't get a proper response value. To solve this, I'm thinking of just signing the transaction in the webview, and leaving the broadcast to be handled by flutter.

Conclusion

Restarting a project that I stopped for personal reasons was not easy, but I plan to continue working on more challenging projects in new directions using new tools and techniques. I hope to grow with other developers by sharing problems and solutions along the way.



If you support me, please vote and follow @anpigon.
Thanks for reading!

Sort:  

Upvoted! Thank you for supporting witness @jswit.

Coin Marketplace

STEEM 0.05
TRX 0.29
JST 0.044
BTC 65678.01
ETH 1880.32
USDT 1.00
SBD 0.38