I have below code in Flutter to use graphql library:
import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
var httpLink = HttpLink(
'https://api.github.com/graphql',
);
var authLink = AuthLink(
getToken: () => 'Bearer <YOUR_PERSONAL_ACCESS_TOKEN>',
);
final Link link = authLink.concat(httpLink);
ValueNotifier<GraphQLClient> client = ValueNotifier(
GraphQLClient(
link: link,
// The default store is the InMemoryStore, which does NOT persist to disk
cache: GraphQLCache(store: HiveStore()),
),
);
const provider = GraphQLProvider(
client: client,
child: MaterialApp(
title: 'demo',
),
);
There is a compile error on the line client: client:
Const variables must be initialized with a constant value.
Try changing the initializer to be a constant expression
Why does it compliant about const? Does it relate to the library?