【Flutter】获取重定向后的url

获取重定向后的url

import 'dart:io';

  Future<String> fetchRedirectedUrl({required String url}) async {
    final myRequest = await HttpClient().getUrl(Uri.parse(url));
    myRequest.followRedirects = false;
    final myResponse = await myRequest.close();
    return myResponse.headers.value(HttpHeaders.locationHeader).toString();
  }

你可能感兴趣的:(Flutter,flutter,前端)