https://stackoverflow.com/questions/52670255/flutter-json-rpc-2-implementation

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc;
import 'package:web_socket_channel/io.dart'; class SymbolDetails extends StatelessWidget {
final String symbolId; SymbolDetails({this.symbolId}); @override
Widget build(BuildContext context) {
var _api = IOWebSocketChannel.connect('wss://api.hitbtc.com/api/2/ws');
var client = json_rpc.Client(_api.cast());
client.sendNotification(
'subscribeTicker',
{'symbol': '$symbolId'},
);
return Scaffold(
appBar: AppBar(
title: Text('$symbolId details'),
),
body: StreamBuilder(
stream: _api.stream,
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.none) {
return Center(
child: Text('Please check your internet connection'),
);
} else if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
}
String _snapshotData = snapshot.data;
Map _response = json.decode(_snapshotData);
return ListView(
children: [
ListTile(
title: Text('Ask price:'),
trailing: Text(
'${_response['params']['ask']}',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
ListTile(
title: Text('Bid price:'),
trailing: Text(
'${_response['params']['bid']}',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
],
);
},
),
);
}
}

  

 

json_rpc_2 implementation的更多相关文章

  1. Design and Implementation of the Sun Network File System

    Introduction The network file system(NFS) is a client/service application that provides shared file ...

  2. [转]Objective-c中@interface、@implementation、@protocal

    原处:http://blog.csdn.net/l271640625/article/details/8393531 以下Objective-c简称OC 从事java开发的程序员们都知道,在java中 ...

  3. Implementation Model Editor of AVEVA in OpenSceneGraph

    Implementation Model Editor of AVEVA in OpenSceneGraph eryar@163.com 摘要Abstract:本文主要对工厂和海工设计软件AVEVA的 ...

  4. 未能正确加载 ”Microsoft.VisualStudio.Editor.Implementation.EditorPackate“包错误解决方法

    今天新来一个同事,帮他搭建开发环境.发现他的vs2012一打开就报错. 错误提示: 未能正确加载 "Microsoft.VisualStudio.Editor.Implementation. ...

  5. Delphi中uses在interfeace和implementation中的区别

    use单元引入分为在interface中引入,如 interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...

  6. IMS Global Learning Tools Interoperability™ Implementation Guide

    Final Version 1.1 Date Issued:            13 March 2012 Latest version:         http://www.imsglobal ...

  7. 未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage”包。

    最近在升级 Visual Studio 2015 Update 3 的过程中,等了很长时间都没一点进展,于是就强行终止了升级程序,但VS也因此出了问题. 后来经过修复,不行,卸载再重装,仍然提示这个错 ...

  8. 未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage,

    未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage, Microsoft.VisualStudio.Editor.Imp ...

  9. An Implementation of Double-Array Trie

    Contents What is Trie? What Does It Take to Implement a Trie? Tripple-Array Trie Double-Array Trie S ...

随机推荐

  1. 为什么需要cookie和session

     为什么需要cookie和session  在Web发展史中,我们知道浏览器与服务器间采用的是 http协议,而这种协议是无状态的,所以这就导致了服务器无法知道是谁在浏览网页,但很明显,一些网页需要知 ...

  2. SAS PROC MEANS 输出每个变量的描述性统计量

    ods listing close;ods output summary=class;proc means data=CC.Model_Params stackods n mean std min m ...

  3. asp.netCore3.0 中使用app.UseMvc() 配置路由

    一.新配置路由策略  在 Asp.Net Core 3.0中默认不再支持app.UserMvc() 方式配置路由 系统. 而是使用新的模式,点击查看asp.netCore3.0区域和路由配置变化 默认 ...

  4. SpringBoot(十六):SpringBoot2.1.1集成fastjson,并使用fastjson替代默认的MappingJackson

    springboot2.1.1默认采用的json converter是MappingJackson,通过调试springboot项目中代码可以确定这点.在springboot项目中定义WebMvcCo ...

  5. Oracle数据库访问客户端 sqldeveloper-18.4.0-376.1900-x64 下载

    Oracle数据库访问客户端 sqldeveloper-18.4.0-376.1900-x64 下载地址:https://pan.baidu.com/s/1RnHVuMcCNZQ7ncHLKDJ33Q

  6. 关于“javax.servlet.include.request_uri”属性值 include 请求 RequestDispatcher.include

    在springMVC的DispatcherServlet类的doService方法中有如下代码: 1 2 3 4 5 6 7 8 9 10 if (WebUtils.isIncludeRequest( ...

  7. Kubernetes之使用kubeadm部署

    参考:https://www.cnblogs.com/caoxb/p/11243472.html 部署虚拟机规划 192.168.1.11 k8s-master 192.168.1.12 k8s-no ...

  8. 浅谈PageRank

    浅谈PageRank 2017-04-25 18:00:09 guoziqing506 阅读数 17873更多https://blog.csdn.net/guoziqing506/article/de ...

  9. [Mobi] cordova requirements,Exception in thread "main" java.lang.NoClassDefFoundError

    Cordova App Preparation https://quasar.dev/quasar-cli/developing-cordova-apps/preparation $ cordova ...

  10. Xcode7.2真机测试问题"The account 'appleID ' has no team with ID ‘’

     在Xcode7(测试版)提出免费真机测试的时候,我立刻在网上搜寻测试步骤,很简单,按照步骤走就可以. 但在7.2以后,突然我的iPhone不能真调了!提示"The account 'app ...