我收到ClientException (内容大小超过指定的 contentLength。在预期 5965 时写入了 10911 字节。尝试将 m4a 文件上传到我的服务器时出错。我尝试从邮递员发送完全相同的请求,它工作得很好。我也能够在flutter中使用完全相同的请求发送imgs和视频。我跟踪了发送方法,它在框架中的Client类中的方法“发送”中给出了错误,这是我的请求代码:
static Future<String> uploadFile(
{Attachment attachment,
List<Attachment> attachments,
String toUserIdForMessage}) async {
Uri _uri = Uri.parse(globalUrl + file + 'Uploads');
http.MultipartRequest _reqss = http.MultipartRequest(
'POST',
_uri,
);
Attachment _attForHeaders = attachment ?? attachments[0];
_reqss.headers.addAll(await headersWToken);
_reqss.fields['ownerType'] =
_attForHeaders.attachmentOwner.index.toString();
_reqss.fields['ownerId'] = _attForHeaders.ownerId.toString();
_reqss.fields['toUserIdForMessage'] = toUserIdForMessage;
if (attachment != null && attachment.path != null)
_reqss.files.add(
await http.MultipartFile.fromPath(
attachment.path,
attachment.path,
),
);
if (attachments != null && attachments.length != 0) {
for (Attachment …Run Code Online (Sandbox Code Playgroud) 我意识到这是这个问题的重复,但这个问题似乎没有任何活动,所以我试图让更多人关注这个问题。
\n我正在尝试使用percentMaterial 图标中的图标,尽管在 fonts.google.com 网站中,它显示了 flutter 实现(下面附有屏幕截图),当我尝试从 flutter 代码调用它时,我收到错误The getter \'percent\' isn\'t defined for the type \'Icons\'.(下面附有屏幕截图)。
这是什么原因,为什么谷歌试图显示一些图标支持颤振,而它显然不支持?
\n\n\n这是我的flutter doctor -v输出:
[\xe2\x88\x9a] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Version 10.0.19041.1348], locale en-US)\n \xe2\x80\xa2 Flutter version 2.8.0 at C:\\Users\\adnan\\flutter\n \xe2\x80\xa2 Upstream repository https://github.com/flutter/flutter.git\n \xe2\x80\xa2 Framework revision cf44000065 (23 hours ago), 2021-12-08 14:06:50 -0800\n \xe2\x80\xa2 Engine revision 40a99c5951\n \xe2\x80\xa2 Dart version 2.15.0\n \xe2\x80\xa2 Pub download mirror https://pub.flutter-io.cn\n …Run Code Online (Sandbox Code Playgroud) 当 的 类型为 时, Flutter Riverpod 不会通知Consumer状态变化,而相同的实现对于其他类型来说效果很好。StateNotifierList
在这里,我提供了一个最小的可重现示例:
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ProviderScope(
child: MaterialApp(
home: MyHomePage(),
),
);
}
}
class CounterState extends StateNotifier<List<int>> {
static final provider = StateProvider(
(ref) => CounterState(),
);
int get last {
print('last');
return state.last;
}
int get length {
print('len');
return state.length;
}
// the body of this will be …Run Code Online (Sandbox Code Playgroud) 我想设计一个小部件,其开头有一个图标,结尾有一个长文本。
当我将它们包装在Row小部件中时,我得到以下结果,因为 Row 不支持多行:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(Icons.face),
Text(
'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.',
maxLines: 5,
),
],
);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我将它们包装在Wrap小部件中时,我克服了溢出问题,但是,由于 是与Text不同的小部件Icon,它从第二行开始,如下所示:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Wrap(
children: [
Icon(Icons.face),
Text(
'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium …Run Code Online (Sandbox Code Playgroud)