Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The argument type 'HttpRequest/*1*/' can't be assigned to the parameter type 'HttpRequest/*2*/'. #28

Open
StukaBoy opened this issue Nov 16, 2021 · 0 comments

Comments

@StukaBoy
Copy link

I'm trying to do a connection with steam for an app but it give me this error when i try to launch the app
Here is my code and the complete error

import 'package:universal_io/io.dart';
import 'package:steam_login/steam_login.dart';

Future<void> main() async {
  // Bind the HttpServer.
  var server = await HttpServer.bind(
    InternetAddress.loopbackIPv4,
    80,
  );

  // Start listening for HttpRequests.
  server.listen((request) async {
    //Check if the path is '/login'
    if (request.uri.path == '/login') {
      // Create OpenId instance with the current request.
      OpenId openId = OpenId(request);

      // Switch the mode
      switch (openId.mode) {
      // No mode is set
        case '':
          {
            //Redirect the user to the authUrl.
            request.response
              ..redirect(openId.authUrl())
              ..close();
            break;
          }
      // Authentication failed/cancelled.
        case 'cancel':
          {
            request.response
              ..write('Auth cancelled')
              ..close();
            break;
          }
      // Usually mode = 'id_res'.
        default:
          {
            // Validate the authentication and the the steamid64.
            String? steamId = await openId.validate();

            // Save the steamid into the session.
            request.session['steamid'] = steamId;

            // Redirect the user.
            request.response
              ..redirect(Uri.parse('http://localhost'))
              ..close();
          }
      }
    } else {
      // Check if the user is already logged
      if (request.session['steamid'] == null) {
        request.response.write('Go to /login in order to log in!');
      } else {
        // If he's logged in display his steam display name.
        // Get the steamapi key here: https://steamcommunity.com/dev/apikey
        Map<String, dynamic>? summaries = await GetPlayerSummaries(
            request.session['steamid'], 'yoursteamapikey');
        request.response
            .write('Thanks for logging in: ${summaries['personname']}');
      }
      request.response.close();
    }
  });
}
Launching lib/testjson.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
lib/testjson.dart:16:30: Error: The argument type 'HttpRequest/*1*/' can't be assigned to the parameter type 'HttpRequest/*2*/'.
 - 'HttpRequest/*1*/' is from 'package:universal_io/src/http/http.dart' ('../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/universal_io-2.0.4/lib/src/http/http.dart').
 - 'HttpRequest/*2*/' is from 'dart:_http'.
      OpenId openId = OpenId(request);
                             ^
Failed to compile application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant