step 6 : add package graphql, configure base repo, constant, graph provider.dart
This commit is contained in:
4
lib/provider/dio_provider.dart
Normal file
4
lib/provider/dio_provider.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final dioProvider = Provider<Dio>((ref) => Dio());
|
||||
22
lib/provider/graphql_provider.dart
Normal file
22
lib/provider/graphql_provider.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:graphql/client.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
|
||||
final graphqlProvider = Provider.family<GraphQLClient, String>(
|
||||
(_, token) {
|
||||
return GraphQLClient(
|
||||
link: (token != "")
|
||||
? HttpLink(
|
||||
Constant.baseURLGraphQl,
|
||||
defaultHeaders: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
)
|
||||
: HttpLink(
|
||||
Constant.baseURLGraphQl,
|
||||
),
|
||||
cache: GraphQLCache(),
|
||||
);
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user