Inner static Class如果它存在,我可以在Kotlin语言中使用什么替代品?如果没有,当我需要static class在Kotlin中使用时,如何解决这个问题?请参阅以下代码示例:
inner class GeoTask : AsyncTask<Util, Util, Unit>() {
override fun doInBackground(vararg p0: Util?) {
LocationUtil(this@DisplayMembers).startLocationUpdates()
}
}
Run Code Online (Sandbox Code Playgroud)
我搜索了很多,没找到任何东西,非常感谢你提前.
我正在使用 flutter_bloc,我想知道我应该使用哪种方法,这两种方法有什么区别?:我读到第一个带有(值)的块不会自动关闭,但实际上我不明白什么是什么意思?
BlocProvider<LoginBloc>.value(
value: (LoginBloc(LoginInitialState(), AuthRepository())),
),
BlocProvider<ProfileBloc>(
create: (context) => ProfileBloc(ProfileInitialState(), AuthRepository()),
),
Run Code Online (Sandbox Code Playgroud) 每次我想在 flutter 中构建 android 项目时都会显示以下消息:
Could not create task ':path_provider_android:generateDebugUnitTestConfig'.
this and base files have different roots: E:\apps\our_class\build\path_provider_android and F:\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_android-2.0.9\android.
Run Code Online (Sandbox Code Playgroud)
我尝试了很多版本的Gradel,但仍然有同样的问题
为什么当我们需要使用带有 flutter_bloc 的 Equatable 类时?,还有我们需要的道具呢?这是在颤振中以块模式创建状态的示例代码,请我需要详细的答案。先感谢您
abstract class LoginStates extends Equatable{}
class LoginInitialState extends LoginStates{
@override
List<Object> get props => [];
}
Run Code Online (Sandbox Code Playgroud) 当我尝试在 Windows 上运行 flutter 应用程序时收到此消息,
\nBuilding Windows application...\nCMake Error at CMakeLists.txt:2 (project):\n Generator\n\n Visual Studio 16 2019\n\n could not find any instance of Visual Studio.\nRun Code Online (Sandbox Code Playgroud)\n我已经安装了 Visual Studio 2022,其中包含许多工具,如下图所示\n
and this what I got from Flutter Doctor:\nE:\\mp\\my_class>flutter doctor\nDoctor summary (to see all details, run flutter doctor -v):\n[\xe2\x88\x9a] Flutter (Channel beta, 2.8.0-3.2.pre, on Microsoft Windows [Version 10.0.22000.318], locale en-US)\n[\xe2\x88\x9a] Android toolchain - develop for Android devices (Android SDK version 31.0.0)\n[\xe2\x88\x9a] Chrome - develop for the web\n[\xe2\x88\x9a] Visual Studio …Run Code Online (Sandbox Code Playgroud) 我遇到过这个错误:
The argument type 'Object' can't be assigned to the parameter type 'Map<String, dynamic>?
Run Code Online (Sandbox Code Playgroud)
在这行代码中:
listMakans = query.docs.map((m) => Makan.fromSnapshot(m.data()!)).toList();
Run Code Online (Sandbox Code Playgroud)
这是(Makan.fromSnapshot)的代码:
Makan.fromSnapshot(Map<String, dynamic>? snapshot)
: id = snapshot!['id'],
owner = snapshot['owner'],
category = snapshot['category'],
hobby = snapshot['hobby'],
business = snapshot['business'],
title = snapshot['title'],
details = snapshot['details'],
latlng = snapshot['latlng'],
from = snapshot['from'].toDate(),
to = snapshot['to'].toDate(),
created = snapshot['created'].toDate(),
updated = snapshot['updated'].toDate();
Run Code Online (Sandbox Code Playgroud)
我不明白这里的对象在哪里?
在控制器中:
RefreshController refreshController = RefreshController(initialRefresh: false);
@override
void onInit() {
fetchServices();
fetchCategory();
super.onInit();
}
Future<bool> fetchServices({bool isRefresh = false}) async {
if (isRefresh) {
currentPage = 1;
} else {
if (currentPage > totalPages) {
refreshController.loadNoData();
return false;
}
}
try {
isLoading(true);
var servicesData = await ServicesDb.fetchServices(currentPage);
var services = servicesData.data;
if (services != null) {
if(isRefresh) {
servicesList.value = services;
} else {
servicesList.value.addAll(services);
}
currentPage++;
totalPages = servicesData.meta.lastPage;
return true;
} else {
return false;
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个使用 Laravel 创建的 Restful API,这个 API 是这样的:
http://127.0.0.1:8000/api/file/pdf/{id}
Run Code Online (Sandbox Code Playgroud)
这是我的下载代码:
public function pdfDownload($id){
$pdf = Cv::findOrfail($id);
return Storage::download('public/pdf/'.$pdf->pdf);
}
Run Code Online (Sandbox Code Playgroud)
它在邮递员和浏览器中工作,它是直接下载文件,但是使用react.js,它不起作用,这是我在react中的代码:
pdfDownload = (id) => {
fetch(' http://127.0.0.1:8000/api/file/pdf/' + id, {
method: 'get',
headers: {
Accept: 'application/octet-stream',
'Content-Type': 'application/octet-stream'
}
}).then((res) => res.json());
};
Run Code Online (Sandbox Code Playgroud)
我在按钮中调用这个函数,如下所示:
<Button color="primary" onClick={() => this.pdfDownload(data.id)}>
Download
</Button>
Run Code Online (Sandbox Code Playgroud)
id 已更正,我确信这一点,我的问题是单击此按钮时如何下载文件..比...
我正在使用 http.dart 包来制作用于登录的 http 帖子,当我在 localhost 和(http 协议)中使用 restful api 时一切正常,但是当我使用(https 协议)将我的后端 api 上传到共享主机时:
I/flutter (12071): HandshakeException: Handshake error in client (OS Error:
I/flutter (12071): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:363))
Run Code Online (Sandbox Code Playgroud)
这是我的http请求代码:
final res = await http
.post(Uri.encodeFull(url),
body: {"email": _user.text, "password": _pass.text},
headers: {'Accept' : 'application/json'});
Run Code Online (Sandbox Code Playgroud)
这是所有调试消息:
E/flutter (12071): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (12071): HandshakeException: Handshake error in client (OS Error:
E/flutter (12071): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:363))
E/flutter (12071): #0 IOClient.send (package:http/src/io_client.dart:33:23)
E/flutter …Run Code Online (Sandbox Code Playgroud) 我想在颤振中获取在 TextField() 中输入的 int 数据,我使用 TextEditingController:
TextEditingController _section_id = new TextEditingController();
Run Code Online (Sandbox Code Playgroud)
并在其中使用此控制器:
TextField(controller: _section_id,
keyboardType: TextInputType.number,)
Run Code Online (Sandbox Code Playgroud)
但是现在,我怎样才能获得 int 数据?我试试这样
Repository().placeAddApiProvider(_section_id.text)
Run Code Online (Sandbox Code Playgroud)
但它只是字符串,并尝试转换为 int,
Repository().placeAddApiProvider(_section_id.text as int)
but it is not work show me this error:
Unhandled Exception: type 'String' is not a subtype of type 'int' in type cast
E/flutter ( 6950): #0 AddPlaceState.build.<anonymous closure> (package:mosul/src/ui/users/add_place.dart:93:50)
E/flutter ( 6950): <asynchronous suspension>
E/flutter ( 6950): #1 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:513:14)
E/flutter ( 6950): #2 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:568:30)
E/flutter ( 6950): #3 GestureRecognizer.invokeCallback (package:flutter/src/gestu...
Run Code Online (Sandbox Code Playgroud)
谢谢