DEV Community

Discussion on: Show me your main.dart - Flutter research

Collapse
 
johnny5development profile image
johnny5development

Hi Keff, thank you for finding this discussion. I think this is holding me back then from using Riverpod then. I use the proxyprovider for providing a callbackfunction from the authenticator to my grpc client, so the grpcclient knows nothing about the authenticator but can always ask for an id token.
I can think of a simple solution for my bloated widgettree, if i build one inherited widget that registers all the objects in a map[class]object and just provides a getter function.

GrpcClient _initGrpcClient(
    BuildContext ctx, Future<String> Function([bool]) idToken) {
  return GrpcClient(
      GrpcSetupParameter(
          remoteHost: SystemConfig.of(ctx).getValue<String>('backendUrl'),
          remotePort: SystemConfig.of(ctx).getValue<int>('backendPort'),
          options: ChannelOptions(
            credentials: ChannelCredentials.secure(),
            idleTimeout: Duration(minutes: 1),
          )),
      interceptorBuilder: () => [
            MyAuthInterceptor.build(metadataProvider: [
              MyAuthorizationMetadataProvider(idToken: idToken),
            ])
          ],
      serviceBuilder: (c, i) => [
            FileTransferService(c, [
              i<MyAuthInterceptor>(),
            ]),
            UserProfileService(c, [
              i<MyAuthInterceptor>(),
            ]),
            SomeServiceClass(c, [
              i<MyAuthInterceptor>(),
            ]),
            SomeServiceClass(c, [i<MyAuthInterceptor>()]),
          ]);
}

Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
nombrekeff profile image
Keff

Yeah I don't now much about Riverpod, but maybe @iizmotabar knows as he has been using it.