Search code examples
iosflutterdarthttpsdio

Flutter when I use dio get data, loading indicator will alway stop a few sec and can not click button in iOS


This is my code:

import 'package:flutter/material.dart';
import 'package:dio/dio.dart';

class ListensScreen extends StatefulWidget {
  _ListensScreenState createState() => _ListensScreenState();
}

class _ListensScreenState extends State<ListensScreen> {
  Dio _dio = new Dio();

  @override
  Widget build(BuildContext context) {

    return new Container(
      alignment: Alignment.center,
      child: FutureBuilder(
          future: _dio.get("https://cnodejs.org/api/v1/topics"),
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              Response response = snapshot.data;
              if (snapshot.hasError) {
                return Text(snapshot.error.toString());
              }
              return ListView(
                children: response.data["data"].map<Widget>((e) =>
                    ListTile(title: Text(e["title"]))
                ).toList(),
              );
            }
            return CircularProgressIndicator();
          }
      ),
    );
  }
}

CircularProgressIndicator always stop a few sec(1~2sec)

It doesn't seem to move much longer than GIF, and I can not click any button. It's very unfriendly to use

Android and Simulator do not have this problem. This problem only display when I test in my iPhone and download app in app store.

Flutter 1.12.13 and dio 3.0.9

I found this problem is on the server. When I use https, this problem will appear on the iOS. Android and Web is nothing wrong. Is iOS something different?

Thanks!


Solution

  • Use this if your SSL web server (like nginx) is behind a firewall and has to use a http proxy to reach OCSP servers in order to implement OCSP Stapling.

    https://github.com/virushuo/ocsp-proxy