title: Dart Dio Package `DioError` `request` Object not defined
body: <p>In the Dart Dio package documentation at <a href="https://pub.dev/packages/dio#handling-errors" rel="nofollow noreferrer">https://pub.dev/packages/dio#handling-errors</a> it describes how to handle errors:</p>
  <pre class="lang-dart prettyprint-override"><code>try {
    //404
    await dio.get('https://wendux.github.io/xsddddd');
  } on DioError catch (e) {
    // The request was made and the server responded with a status code
    // that falls out of the range of 2xx and is also not 304.
    if (e.response) {
      print(e.response.data)
      print(e.response.headers)
      print(e.response.request)
    } else {
      // Something happened in setting up or sending the request that triggered an Error
      print(e.request)
      print(e.message)
    }
  }
  </code></pre>
  <p>The code makes sense and gives me the options I need to understand what happened with my request, but the Dart Analysis tool in Android Studio (I'm working on a Flutter app) reacts violently to it.</p>
  <p>I can fix many of the analyzer's complaints by adding null checks to the code as recommended by Android Studio:</p>
  <pre class="lang-dart prettyprint-override"><code>try {
      var response = await dio.get(url, options: options);
      print('Response: $response');
      return response.data;
  } on DioError catch (e) {
      // The request was made and the server responded with a status code
      // that falls out of the range of 2xx and is also not 304.
      if (e.response != null) {
        print(e.response!.data);
        print(e.response!.headers);
        print(e.response!.request);  &lt;-- line 64
      } else {
        // Something happened in setting up or sending the request that triggered an Error
        print(e.request);  &lt;-- line 67
        print(e.message);
      }
  }
  </code></pre>
  <p>but the analyzer still complains about the <code>request</code> object:</p>
  <pre><code>error: The getter 'request' isn't defined for the type 'Response&lt;dynamic&gt;'. (undefined_getter at [particle_cloud] lib\src\particle.dart:64)
  error: The getter 'request' isn't defined for the type 'DioError'. (undefined_getter at [particle_cloud] lib\src\particle.dart:67)
  </code></pre>
  <p>I'm assuming the DioError should have the appropriate request object defined, how do I get this code fixed so it runs?</p>