Closed yuhorun closed 4 years ago
Flutter web runs in the browser and does not support dart.io. I think you want the package:grpc/grpc_web.dart
package.
this is my code:
` import 'package:flutter/material.dart'; import 'dart:async'; import 'package:grpc/grpc.dart'; import 'package:application/model/hello.pbgrpc.dart';
void main() => runApp(new FlutterGrpcApp());
class FlutterGrpcApp extends StatefulWidget { _FlutterGrpcAppState createState() => _FlutterGrpcAppState(); }
class _FlutterGrpcAppState extends State
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
title: Text("Grpc ❤️ Flutter"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children:
Future
`
Flutter web runs in the browser and does not support dart.io. I think you want the
package:grpc/grpc_web.dart
package.
Because flutterweb is converted to js.i shoud use js-grpc?right? Seems to have found a way thank you!
@yuhorun can you share your solution? I'm using the grpc_web but I get a gRPC Error (14, XhrConnection status 0)
@yuhorun share your solution please, I am stuck with the same problem. thx
How did you solve it? I have the same problem! Thank you
@yuhorun can you share your solution? I'm using the grpc_web but I get a
gRPC Error (14, XhrConnection status 0)
I have the same issue, any update ?
@yuhorun can you share your solution? I'm using the grpc_web but I get a
gRPC Error (14, XhrConnection status 0)
I have the same issue, any update ?
grpc/grpc_web.dart , you can try this package. any question can contact me.
How did you solve it? I have the same problem! Thank you
grpc/grpc_web.dart , you can try this package. any question can contact me.
How did you solve it? I have the same problem! Thank you
grpc/grpc_web.dart , you can try this package. any question can contact me.
How did you solve it? I have the same problem! Thank you
grpc/grpc_web.dart , you can try this package. any question can contact me.
Yes, but:
GrpcWebClientChannel channel = GrpcWebClientChannel.xhr(Uri.parse('http://$serverAddr:$serverPort'));
doesn't work. I got gRPC Error (14, XhrConnection status 0)
.
And the server side works well with bloomRPC.
I might need to use envoy as a web proxy in front of my server?
How did you solve it? I have the same problem! Thank you
grpc/grpc_web.dart , you can try this package. any question can contact me.
Yes, but:
GrpcWebClientChannel channel = GrpcWebClientChannel.xhr(Uri.parse('http://$serverAddr:$serverPort'));
doesn't work. I got
gRPC Error (14, XhrConnection status 0)
. And the server side works well with bloomRPC. I might need to use envoy as a web proxy in front of my server?
sorry,time is long. i cant find my code.but i remember use no proxy。you can see this replied example: envoy. (although i use no proxy, but i success.)
I am using a Go backend and used the github.com/improbable-eng/grpc-web/go/grpcweb
package instead of a proxy such as envoy. The GrpcWebClientChannel is also working with localhost for development.
I can use it normally in a dart function.When I integrate this function into the flutter-web,The request will give an error.Can anyone use grpc normally in flutter-web?I wonder if there is something wrong with my code. thank you!
dependencies: flutter: sdk: flutter grpc: ^2.1.3 protobuf: ^1.0.1 cupertino_icons: ^0.1.2
Repro steps
nomal:![image](https://user-images.githubusercontent.com/45552382/71597003-88d7bb00-2b7c-11ea-973f-6fe356073f15.png)
flutter-web Error:![image](https://user-images.githubusercontent.com/45552382/71596948-5d54d080-2b7c-11ea-92b3-d934a4a6a53f.png)
Expected result: The request should be invoked normally.and return a result. Actual result: when call
$grpc.ResponseFuture<$0.ResponseHello> sayHello($0.RequestHello request,{$grpc.CallOptions options})
return error: Caught error: gRPC Error (14, Error connecting: Unsupported operation: Socket constructor)