5

I hope someone can help with my issue I am creating at the moment an Flutter app for Web and Mobile and I want to use GRPC and WebGrpc. With Grpc Everything runs fine but with Web Grpc I got an error

   if (kIsWeb) {
    print("flutter web");
    clientChannel =
        GrpcWebClientChannel.xhr(Uri.parse('http://192.168.2.146:8880'));
    AuthClient(clientChannel).authenticate(AuthenticationRequest()
      ..login = "Apfel"
      ..password= "Hello").then((res) => print(res)).catchError((err) => print(err));
  } else {
    print("flutter mobil");
    clientChannel = ClientChannel('192.168.2.146',
        port: 3009,
        options:
        ChannelOptions(credentials: ChannelCredentials.insecure()));
  }

I got the following error Expected a value of type 'ClientChannel', but got one of type 'GrpcWebClientChannel'

Moritz Rinckens
  • 105
  • 2
  • 6
  • Did you find a solution to make it work for all the platforms? – Ayad Apr 06 '21 at 11:39
  • This is the answer https://stackoverflow.com/questions/58710226/how-to-import-platform-specific-dependency-in-flutter-dart-combine-web-with-an – forest May 12 '21 at 05:39

0 Answers0