Flutter異常信息

  Cannot run with sound null safety, because the following dependencies don‘t support
  解決辦法:終端執(zhí)行flutter run --no-sound-null-safety 或者在pubspec.yaml升級依賴版本到支持null-safety版本
Expected a key while parsing a block mapping.
pubspec.yaml里的assets 要對齊不要留空格,很無語的bug提示信息也很不友好
flutter:
  uses-material-design: true
  assets:
     - images/bg1.png
Flutter異常:
Could not find a generator for route RouteSettings("second_route", null) in the _WidgetsAppState.  注冊路由的路由名稱與你在pushname使用的路由名稱不匹配
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: DioError [DioErrorType.DEFAULT]: type 'String' is not a subtype of type 'Map<String, dynamic>'
Retrofit自動生成的代碼改成如下所示,原因是后臺接口返回的Response的contentType是text/html而不是application/json,而這個接口是老接口后臺不好改動所以只能自己修改Retrofit自動生成的代碼_dio.fetch<T>的泛型T傳String 然后自己把String轉(zhuǎn)成json,再把json轉(zhuǎn)成對象返回
@override
  Future<BaseResponse<Object?>> requestCode(loginParam) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _headers = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(loginParam);
    final _result = await _dio.fetch<String>(
        _setStreamType<BaseResponse<String?>>(
            Options(method: 'POST', headers: _headers, extra: _extra)
                .compose(_dio.options, 'securityCode/send',
                    queryParameters: queryParameters, data: _data)
                .copyWith(baseUrl: baseUrl ?? _dio.options.baseUrl)));
    final value = BaseResponse<Object?>.fromJson(
      jsonDecode(_result.data ?? ""),
      (json) => jsonEncode(json),
    );
    return value;
  }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容