我一直在尝试在使用时添加监听器DefaultTabController。但是,每次我添加 aTabController以便获取 和 中的当前索引时TabBar,TabBarView我都会在它们之间失去同步。
这是我的代码如下:
@override
Widget build(BuildContext context) {
return new DefaultTabController(
length: subPages.length,
child: new Scaffold(
appBar: appBar('homepage'),
body: new Center(
child: new NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
new SliverAppBar(
backgroundColor: Colors.white,
title: new TabBar(
labelColor: Colors.black,
indicatorColor: Colors.black,
labelStyle: new TextStyle(fontWeight: FontWeight.bold),
tabs: subPages.map((String str) => new Tab(text: str)).toList(),
),
),
];
},
body: new TabBarView(
children: subPages.map((String str) {
return new ListView(
padding: const …Run Code Online (Sandbox Code Playgroud) 我正在构建一个flutter应用程序,该应用程序利用图像选择器捕获或从图库中选择图像,但是我很难将图像从客户端发布到我的服务器上。
从我收集到的信息中,我可以通过将图像文件转换为字节,然后将其作为BASE64发送来通过JSON发送本地图像。
import 'dart:convert';
import 'package:crypto/crypto.dart';
Future<Map> _avatarSubmit() async {
String url = api + '/api/account';
http.Response response = await http.post(Uri.encodeFull(url), headers: {
"Accept": "application/json",
"Cookie": "MYCOOKIE=" + sessionCookie2 + "; MYTOKENS=" + sessionCookie3,
"Content-type": "multipart/form-data",
}, body: {
"image": "",
});
Map content = JSON.decode(response.body);
return content;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何将设备中的图像文件转换为字节,以便随后可以使用加密插件将其转换为BASE64?
先感谢您。