AS-Devs / signalr_flutter

A flutter plugin for .net SignalR client.
https://pub.dev/packages/signalr_flutter
MIT License
18 stars 28 forks source link

Build failed with an exception in V0.0.4 #4

Closed AliEasy closed 4 years ago

AliEasy commented 4 years ago

Hey So I updated to the last version(0.0.4) but when Im trying to build, an exception occurs.

e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.2\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (11, 12): Redeclaration: CallMethod
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.2\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (19, 8): Redeclaration: SignalR
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.2\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (13, 14): Redeclaration: SignalRFlutterPlugin
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (12, 12): Redeclaration: CallMethod
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (13, 20): Cannot access '<init>': it is private in 'CallMethod'
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (14, 14): Cannot access '<init>': it is private in 'CallMethod'
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (15, 9): Cannot access '<init>': it is private in 'CallMethod'
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (16, 22): Cannot access '<init>': it is private in 'CallMethod'
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (17, 23): Cannot access '<init>': it is private in 'CallMethod'
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalR.kt: (20, 8): Redeclaration: SignalR
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (13, 14): Redeclaration: SignalRFlutterPlugin
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (44, 25): Type mismatch: inferred type is Map<String, String>? but MethodChannel.Result? was expected
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (44, 25): Type mismatch: inferred type is Map<String, String> but MethodChannel.Result was expected
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (44, 25): Type mismatch: inferred type is Map<???, ???> but MethodChannel.Result was expected
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (45, 36): Type mismatch: inferred type is Map<???, ???> but MethodChannel.Result was expected
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (45, 48): Too many arguments for public final fun connectToServer(url: String, hubName: String, queryString: String, result: MethodChannel.Result): Unit defined in dev.asdevs.signalr_flutter.SignalR
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (45, 79): Too many arguments for public final fun connectToServer(url: String, hubName: String, queryString: String, result: MethodChannel.Result): Unit defined in dev.asdevs.signalr_flutter.SignalR
e: E:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\signalr_flutter-0.0.4\android\src\main\kotlin\dev\asdevs\signalr_flutter\SignalRFlutterPlugin.kt: (65, 28): Not enough information to infer type variable T

FAILURE: Build failed with an exception.

Below is my code:

 SignalR signalR;
  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    signalR = SignalR('http://xxxxxxx/', "notificationHub",
        statusChangeCallback: _onStatusChange,
        hubCallback: _onNewMessage,
        );
  }

  _onStatusChange(String status) {
    if (mounted) {
      setState(() {
        _signalRStatus = status;
      });
    }
  }

  _onNewMessage(dynamic message) {
    print(message);
  }

  _buttonTapped() async {
    final res =
        await signalR.invokeMethod("sendNotifications", arguments: [null]);
    final snackBar =
        SnackBar(content: Text('SignalR Method Response: ${res.toString()}'));
    _scaffoldKey.currentState.showSnackBar(snackBar);
  }

How can I fix this?!

AyonAB commented 4 years ago

Please Do a flutter clean and try again.

AliEasy commented 4 years ago

Did the trick Thanks.