title: Flutter: ERR_NAME_NOT_RESOLVED when backend redirects with a custom scheme
body: <p>I am trying to login via Twitch and, to do that I am using <a href="https://pub.dev/packages/url_launcher" rel="nofollow noreferrer">https://pub.dev/packages/url_launcher</a> and <a href="https://pub.dev/packages/uni_links" rel="nofollow noreferrer">https://pub.dev/packages/uni_links</a>. The code works well on iOS, but not on Android.</p>
  <p>The process is:</p>
  <ul>
  <li>Click on &quot;Sign in with Twitch&quot;</li>
  <li>Opens a browser via <code>launchUrl(_url)</code></li>
  <li>Accept authorization of Twitch popup</li>
  <li>Redirects to the callback of my backend server</li>
  <li>Backend: Create/Retrieve the user</li>
  <li>Backend: Returns a 307 HTTP with url: <code>customscheme://auth/twitch?access_token=...</code></li>
  <li>Listens the Deep Link: Close the browser and stores the token in the device</li>
  </ul>
  <p>On Android, when my browser tries to redirect with my customscheme, the device browser returns an error:</p>
  <pre><code>Webpage not available
  
  The webpage at
  http://customscheme//auth/twitch?access_token=XXX
  could not be loaded because:
  
  net::ERR_NAME_NOT_RESOLVED
  </code></pre>
  <p>The <code>customscheme</code> is replaced by mine, and it works when I test it with the command:</p>
  <p><code>adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d &quot;customscheme://auth/twitch&quot;</code>.</p>
  <p>So it seems it does not understand the custom scheme from the webview, and handle it like a simple HTTP url.</p>
  <p>Here is my code:</p>
  <pre><code>  void logWithTwitch() async {
      assert(dotenv.env['TWITCH_CLIENT_ID'] != null);
      assert(dotenv.env['TWITCH_REDIRECT_URI'] != null);
  
      final String twitchClientId = dotenv.env['TWITCH_CLIENT_ID']!;
      final String twitchRedirectUri = dotenv.env['TWITCH_REDIRECT_URI']!;
      final List&lt;String&gt; scopes = [
        'user:read:email',
      ];
      final Uri _url = Uri(
          scheme: 'https',
          host: 'id.twitch.tv',
          path: 'oauth2/authorize',
          queryParameters: {
            'client_id': twitchClientId,
            'redirect_uri': twitchRedirectUri,
            'response_type': 'code',
            'scope': scopes.join(' '),
            'force_verify': 'true',
          });
  
      if (await canLaunchUrl(_url)) {
        await launchUrl(_url);
      } else {
        print('cannot open url');
      }
    }
  
  ...
  
  _sub = linkStream.listen((String? link) {
      if (link == null) {
          return;
      }
  
      final _url = Uri.parse(link);
      if (_url.host == 'auth' &amp;&amp; _url.path == '/twitch') {
          closeInAppWebView();
          // Handle Authentication
      }
  }, onError: (err) {
      // Handle exception by warning the user their action did not succeed
  });
  </code></pre>
  <p>Thank you for your help!</p>