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. Element + Vue I18n动态import加载国际化语言包翻译文件

    需求 项目为多页应用,包含产品a.b.c.d.e,每个产品都有自己的翻译文件.一次加载所有翻译文件是极度不合理的.于是考虑动态加载. 实现 参考官方文档:延迟加载翻译 项目结构 │ ├── dist ...

  2. java项目中使用ffmpeg剪辑部分视频

    在项目中,有个需求是分享视频链接地址到微信.qq或者朋友圈,只能试看两分钟,本想着通过h5界面就能控制实现效果,代码如下,但是前端终究不是安全的,其次监听事件,如果拉播放进度条,中途停顿多次,就会出现 ...

  3. TP 控制器和模型里面order 写法不同

      控制器: Db::table('think_user')->where('status=1')->order('id desc')->limit(5)->select(); ...

  4. windows7平台android studio新建Android项目,报错

    Failed to install the following Android SDK packages as some licences have not been accepted. platfo ...

  5. 【C++】C++的拷贝控制

    目录结构: contents structure [-] 拷贝.赋值与销毁 拷贝构造函数 拷贝初始化 参数和返回值 拷贝赋值运算符 析构函数 三五法则 拷贝控制和资源管理 交换操作 对象移动 右值引用 ...

  6. 配置Pods和containers--为Containers和Pods分配CPU资源

    指定CPU请求和CPU限制 要为容器指定CPU请求,在容器资源清单中使用resources:requests字段.要指定CPU限制,使用resources:limits. cpu-request-li ...

  7. advanceInstaller制作中文安装界面

    AdvanceInstaller15.7 ,上述画框选择.

  8. 深入Nginx之《常用参数配置技巧》

    常见参配置实战技巧 下面会讲解实战中应该怎么配置更为合理. 1.user 默认是nobody,如果使用nobody,Nginx在运行过程中会出现很多操作没有权限,比如写硬盘.一般都是用低于root级别 ...

  9. c# socket 心跳 重连

    /// <summary> /// 检查一个Socket是否可连接 /// </summary> /// <param name="socket"&g ...

  10. 拥抱TF2.0的时代来了

    AI = 算法 + 实现 忘掉 tf 1.0吧!!! TPU tf 加速硬件 学习建议 忘记1.0 Tensorflow 和Pytorch 选择一个主修 Keras 逐渐淡出 TF.kreas Pyt ...