我的 main.dart 中有一个 TabBarView,每个选项卡都有一个类来显示内容(它是 listview 对象),当我在选项卡之间切换时,listview 页面每次都会刷新,tabbarview 是否正常?我不希望每次在标签之间切换时它都会刷新。
是我班级的问题吗?如何解决这个问题?代码是这样的。
class ListWidget extends StatefulWidget {
final catID;
ListWidget(this.catID);
_ListWidgetState createState() => new _ListWidgetState(catID);
}
class _ListWidgetState extends State<ListWidget> {
var catID;
void initState() {
super.initState();
_fetchListData();
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(.......
}
Run Code Online (Sandbox Code Playgroud) new ListView(
children: [
new SizedBox(
height: 100.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
new Text("hi"),
new Text("hi"),
new Text("hi"),
],
),
),
],
),
Run Code Online (Sandbox Code Playgroud)
我使用了大小的盒子,似乎仍然有错误.
这是我的小部件树:SingleChildScrollView - > Column - > children
Performing hot reload... flutter: ??? EXCEPTION CAUGHT BY RENDERING LIBRARY ?????????????????????????????????????????????????????????? flutter: The following assertion was thrown during performResize(): flutter: Vertical viewport was given unbounded height. flutter: Viewports expand in the scrolling direction to fill their container.In this case, a vertical flutter: viewport was given an unlimited …Run Code Online (Sandbox Code Playgroud) 我需要在上传到服务器之前调整图像大小。
我正在使用 io 和图像包。
import 'dart:io';
import 'package:image/image.dart' as Img;
Run Code Online (Sandbox Code Playgroud)
使用这个功能
uploadImages(File image_File) async {
Img.Image image_temp = Img.decodeImage(image_File.readAsBytesSync());
Img.Image resized_img = Img.copyResize(image_temp, 800);
File resized_file = File('resized_img.jpg')
..writeAsBytesSync(Img.encodeJpg(resized_img));
var stream = new http.ByteStream(DelegatingStream.typed(resized_file.openRead()));
var length = await resized_file.length();
var uri = Uri.parse("https://myserver.com/upload.php");
var request = new http.MultipartRequest("POST", uri);
var multipartFile = new http.MultipartFile('file', stream, length,
filename: p.basename("resized_image.jpg"));
request.files.add(multipartFile);
var response = await request.send();
print(response.statusCode);
response.stream.transform(utf8.decoder).listen((value) {
print(value);
});
}
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,应用程序只是冻结并且图像没有上传到服务器。
我正在尝试通过网络视图为我的 flutter 应用程序集成 PayPal 支付。
\n\nreturn new MaterialApp(\nroutes: {\n"/": (_) => new WebviewScaffold(\n url: "https://www.paypal.com/cgi-bin/webscr? business=xxxx.com&cmd=_xclick&item_name=Hot+Sauce-12oz.+Bottle&amount=5.95¤cy_code=USD",\n appBar: new AppBar(\n title: new Text(\n "Payment",\n ),\n ),\n)\n},\n);\nRun Code Online (Sandbox Code Playgroud)\n\n当我运行该页面时,应用程序意外关闭并显示错误消息
\n\nUnsupported value: <FlutterError: 0x1c422d200> of type FlutterError\nLost connection to device.
这是我的扑动医生。
\n\nRunning flutter doctor...\nDoctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.1 17B1003, locale en-HK)\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK 26.0.2)\n[\xe2\x9c\x93] iOS toolchain - develop …Run Code Online (Sandbox Code Playgroud) 我有一个带有很多特殊字符和表情符号的字符串需要传递给php,特殊字符如&和[]{},导致php错误,我尝试过
ReplaceAll(new RegExp('&'), '%26');
处理 & ,但是有很多特殊字符也会导致错误,那么在 php 中处理不会导致任何错误的特殊字符的最佳方法是什么?
我正在使用image_picker从图库中获取一些图像,并且将图像的路径保存在列表中,例如
/ private / var / mobile /容器/数据/应用程序/E633FB78-77D3-4913-B37A-496BFBAAD00C/tmp/image_picker_EA6D2836-3EAD-438C-AEEE-21CB3500ED28-9410-00000706FA96031D.jpg
如何从抖动路径中打开图像?
我尝试了Image.file,但是它不起作用,请帮忙。