You've already forked flutter-rp-example
added support for web ; bumped dart_core_sdk version to 1.13.2
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:grpc/grpc.dart';
|
||||
import 'package:grpc/grpc_or_grpcweb.dart';
|
||||
import 'package:sampleapp/services/auth/auth.dart';
|
||||
|
||||
class AuthInterceptor extends ClientInterceptor {
|
||||
@@ -17,15 +18,19 @@ class AuthInterceptor extends ClientInterceptor {
|
||||
}
|
||||
|
||||
class GrpcClient {
|
||||
static Client initializeClient(AuthService authService, String host, int port, Client Function(ClientChannel, List<ClientInterceptor>) clientFactory) {
|
||||
static Client initializeClient(
|
||||
AuthService authService,
|
||||
String host,
|
||||
int port,
|
||||
Client Function(GrpcOrGrpcWebClientChannel, List<ClientInterceptor>)
|
||||
clientFactory,
|
||||
) {
|
||||
final interceptor = AuthInterceptor(authService);
|
||||
final channel = ClientChannel(
|
||||
host,
|
||||
final channel = GrpcOrGrpcWebClientChannel.toSingleEndpoint(
|
||||
host: host,
|
||||
port: port,
|
||||
options: const ChannelOptions(
|
||||
credentials: ChannelCredentials.secure(),
|
||||
),
|
||||
transportSecure: true,
|
||||
);
|
||||
return clientFactory(channel, [interceptor]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user