来自 SocketClientConfig 的 initPayload 不接受类似 Json 的数据
initPayload from SocketClientConfig is not accepting Json-like data
描述错误
我收到以下错误消息
The argument type 'Map<String, Map<String,String>>' can't be assigned to the parameter type 'Future<dynamic> Function()'.
用于此代码的 initPayload
参数:
static final WebSocketLink webSocketLink = WebSocketLink(
url: 'wss://hasura.io/learn/graphql',
config: SocketClientConfig(
autoReconnect: true,
inactivityTimeout: Duration(seconds: 30),
initPayload: {'headers': {'Authorization': _token}},
),
);
复制
- 正在关注 GraphQL Flutter Tutorial。
- 根据initPayload property帮助:
Can be null, but must be a valid json structure if provided.
- 根据GetInitPayload typedef帮助:
typedef GetInitPayload = FutureOr<dynamic> Function();
答案可以在this post找到。
描述错误
我收到以下错误消息
The argument type 'Map<String, Map<String,String>>' can't be assigned to the parameter type 'Future<dynamic> Function()'.
用于此代码的 initPayload
参数:
static final WebSocketLink webSocketLink = WebSocketLink(
url: 'wss://hasura.io/learn/graphql',
config: SocketClientConfig(
autoReconnect: true,
inactivityTimeout: Duration(seconds: 30),
initPayload: {'headers': {'Authorization': _token}},
),
);
复制
- 正在关注 GraphQL Flutter Tutorial。
- 根据initPayload property帮助:
Can be null, but must be a valid json structure if provided.
- 根据GetInitPayload typedef帮助:
typedef GetInitPayload = FutureOr<dynamic> Function();
答案可以在this post找到。