added support for web ; bumped dart_core_sdk version to 1.13.2

This commit is contained in:
2026-06-24 17:05:42 +02:00
parent fff5617757
commit 3efe4dcca6
20 changed files with 734 additions and 30 deletions

View File

@@ -177,6 +177,7 @@ class AuthService {
Future<void> setAccessToken(String token) async {
final prefs = await SharedPreferences.getInstance();
prefs.setString('accessToken', token);
accessToken = token;
}

View File

@@ -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]);
}
}
}