你好,我尝试使用 dio 包上传图像,但我必须为图像设置 contentType 但我无法设置它并在设置 MediaType 时出现此错误 ====> 未为类型“AnalyzeData”定义方法“MediaType” .
这是我的代码
Dio dio = new Dio();
dio.options.headers = {
'token': token,
};
try {
String ip = await getServerIP();
FormData formData = new FormData.fromMap({
"front":front==null?null: MultipartFile.fromFileSync(
front,
filename: "image.png",
contentType: MediaType() <=== get error in this line
),
}
);
response = await dio.post("$url", data: formData);
Run Code Online (Sandbox Code Playgroud)
我如何修复它我使用的是最新版本的 Dio 包
我将本地 android 库(.aar)推送到我的 flutter 项目并更改 android 目录中的 gradle 文件,这是我的 build.gradle
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
google()
jcenter()
flatDir
{
dirs 'pecpayment-release'
}
Maven { url 'https://maven.fabric.io/public' }
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
这是我的 app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if …Run Code Online (Sandbox Code Playgroud) 这是我的代码,我有一行包含两个堆栈,每个堆栈都有一个列表视图,左侧小部件有一个包含 reordablelistView 的堆栈,但是当拖动其中的元素时会出现此错误
Scaffold(
body: Container(
width: width,
child: Row(
children: <Widget>[
RightWidget(),// a listview
Container(
width: 1.5,
color: Colors.grey,
),
LeftWidget()
],
),
),)
Run Code Online (Sandbox Code Playgroud)
我的 reordablelistview 是
class _RightWidgetState extends State<RightWidget> {
@override
Widget build(BuildContext context) {
print('right widget called');
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Stack(
children: <Widget>[
Container(
color: Color(0xFF1B1D22),
width: (1 / 4) * width + 10,
child://new reordable list added
ReorderableListView(
children:
List.generate(Provider.of<ClassroomBlac>(context).classes[Provider.of<ClassroomBlac> (context).numberclass].moves.length, (index) {
return _itemBuilder(context,index);
}), onReorder: (int oldIndex, …Run Code Online (Sandbox Code Playgroud)