I'm using Serverpod to set up my Flutter app.
However, one of the files which I haven't touched is giving the following error:
The named parameter 'context' isn't defined.
Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'context'.dartundefined_named_parameter
The error comes from the context: context
part from the protocol/client.dart
file below:
class Client extends _i1.ServerpodClient {
Client(
String host, {
_i3.SecurityContext? context,
_i1.AuthenticationKeyManager? authenticationKeyManager,
}) : super(
host,
_i4.Protocol(),
context: context,
authenticationKeyManager: authenticationKeyManager,
) {
example = _EndpointExample(this);
}
late final _EndpointExample example;
@override
Map<String, _i1.EndpointRef> get endpointRefLookup => {'example': example};
@override
Map<String, _i1.ModuleEndpointCaller> get moduleLookup => {};
}
I have tried flutter clean
and restarting VS code, plus updating my flutter sdk, however with no success.
Any idea what I could do?
You're using a version of
serverpod_service_client
that is not compatible with the latest version ofserverpod_client
(Looks like you haveserverpod_client
updated, butserverpod_service_client
is still on an older version)._i1
is an import alias for theserverpod_client
package, and as you can see in the new constructor ofServerpodClient
, there is nocontext
parameter (most likely replaced bysecurityContext
):serverpod_client/lib/src/serverpod_client_io.dart, line 21
And in the latest version of
serverpod_service_client
the constructor ofClient
class should be like this:serverpod_service_client/lib/src/protocol/client.dart, line 234
Which differs from the code you posted. So you can fix it by either upgrading
serverpod_service_client
or downgradingserverpod_client
to make both packages compatible.