Skip to content

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

@StukaBoy

Description

@StukaBoy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions