Flutter异常信息

  Cannot run with sound null safety, because the following dependencies don‘t support
  解决办法:终端执行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'
Retrofit自动生成的代码改成如下所示,原因是后台接口返回的Response的contentType是text/html而不是application/json,而这个接口是老接口后台不好改动所以只能自己修改Retrofit自动生成的代码_dio.fetch的泛型T传String 然后自己把String转成json,再把json转成对象返回
@override
  Future> requestCode(loginParam) async {
    const _extra = {};
    final queryParameters = {};
    final _headers = {};
    final _data = {};
    _data.addAll(loginParam);
    final _result = await _dio.fetch(
        _setStreamType>(
            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.fromJson(
      jsonDecode(_result.data ?? ""),
      (json) => jsonEncode(json),
    );
    return value;
  }

你可能感兴趣的:(Flutter异常信息)