Using Grpc Web in Flutter Project

1.5k Views Asked by At

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'

0

There are 0 best solutions below