小编Osa*_*med的帖子

Kotlin中的静态内在类

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)

我搜索了很多,没找到任何东西,非常感谢你提前.

java static class kotlin

26
推荐指数
2
解决办法
7878
查看次数

BlocProvider.value 与 BlocProvider(create:)

我正在使用 flutter_bloc,我想知道我应该使用哪种方法,这两种方法有什么区别?:我读到第一个带有(值)的块不会自动关闭,但实际上我不明白什么是什么意思?

BlocProvider<LoginBloc>.value(
  value:  (LoginBloc(LoginInitialState(), AuthRepository())),
  ),

  

 BlocProvider<ProfileBloc>(
         create:  (context) => ProfileBloc(ProfileInitialState(), AuthRepository()),
       ),
Run Code Online (Sandbox Code Playgroud)

flutter flutter-bloc

15
推荐指数
2
解决办法
2万
查看次数

构建 Gradle 时出现问题(无法创建任务 ':path_provider_android:generateDebugUnitTestConfig')。在 android 的 flutter 中

每次我想在 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,但仍然有同样的问题

android gradle flutter

8
推荐指数
5
解决办法
2万
查看次数

使用带有 flutter_bloc 的 Equatable 类

为什么当我们需要使用带有 flutter_bloc 的 Equatable 类时?,还有我们需要的道具呢?这是在颤振中以块模式创建状态的示例代码,请我需要详细的答案。先感谢您

abstract class LoginStates extends Equatable{}

class LoginInitialState extends LoginStates{
  @override
  List<Object> get props => [];

}
Run Code Online (Sandbox Code Playgroud)

equatable flutter flutter-bloc

7
推荐指数
2
解决办法
2765
查看次数

桌面版 flutter,Visual Studio 2022 问题

当我尝试在 Windows 上运行 flutter 应用程序时收到此消息,

\n
Building 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.\n
Run Code Online (Sandbox Code Playgroud)\n

我已经安装了 Visual Studio 2022,其中包含许多工具,如下图所示\n在此输入图像描述

\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)

flutter flutter-desktop visual-studio-2022

7
推荐指数
1
解决办法
1万
查看次数

参数类型“Object”无法分配给参数类型“Map &lt;String,dynamic&gt;?”

我遇到过这个错误:

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)

我不明白这里的对象在哪里?

object flutter

6
推荐指数
1
解决办法
4995
查看次数

flutter中SmartRefresher的错误(不要使用一个refreshController到多个SmartRefresher,这会导致一些意想不到的错误)

在控制器中:

 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)

pull-to-refresh flutter

6
推荐指数
1
解决办法
9544
查看次数

在反应中下载文件

我有一个使用 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 已更正,我确信这一点,我的问题是单击此按钮时如何下载文件..比...

download laravel reactjs

5
推荐指数
1
解决办法
2万
查看次数

将 https 与 flutter http.dart 包一起使用时出错

我正在使用 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)

http flutter

5
推荐指数
1
解决办法
9193
查看次数

我如何在颤振中从 TextEditingController 获取 int 数据

我想在颤振中获取在 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)

谢谢

textfield flutter

5
推荐指数
2
解决办法
1万
查看次数