I am trying to use graphql_flutter (https://pub.dev/packages/graphql_flutter) for my MVVM architecture. (https://stacked.filledstacks.com/docs/getting-started/overview) I got this error below from the package graphql_flutter when I try to run my code
`../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/graphql-5.1.2/lib/src/links/websocket_link/websocket_client.dart:577:7: Error: The non-abstract class 'GraphQLWebSocketChannel' is missing implementations for these members:
- WebSocketChannel.ready Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class GraphQLWebSocketChannel extends StreamChannelMixin<dynamic> ^^^^^^^^^^^^^^^^^^^^^^^ ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-2.3.0/lib/src/channel.dart:56:22: Context: 'WebSocketChannel.ready' is defined here. final Future<void> ready = Future.value();`
This is my code in the main.dart file. I am getting the error as long as I have imported the package.
import 'package:flutter/material.dart';
import 'package:testing/app/app.locator.dart';
import 'package:testing/ui/common/app_colors.dart';
import 'package:testing/ui/setup/setup_bottom_sheet_ui.dart';
import 'package:testing/ui/setup/setup_dialog_ui.dart';
import 'package:stacked_services/stacked_services.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'app/app.router.dart';
void main() {
setupLocator();
setupDialogUi();
setupBottomSheetUi();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
HttpLink httpLink = HttpLink("https://api.github.com/graphql");
AuthLink authLink = AuthLink(
getToken: () async => 'Bearer PERSONAL_ACCESS_TOKEN',
);
Link link = authLink.concat(httpLink);
ValueNotifier<GraphQLClient> qlClient = ValueNotifier(
GraphQLClient(
link: link,
// The default store is the InMemoryStore, which does NOT persist to disk
cache: GraphQLCache(store: HiveStore()),
),
);
return GraphQLProvider(
client: qlClient,
child: MaterialApp(
title: 'Flutter Demo',
theme: Theme.of(context).copyWith(
primaryColor: kcBackgroundColor,
focusColor: kcPrimaryColor,
textTheme: Theme.of(context).textTheme.apply(
bodyColor: Colors.black,
),
),
initialRoute: Routes.startupView,
onGenerateRoute: StackedRouter().onGenerateRoute,
navigatorKey: StackedService.navigatorKey,
navigatorObservers: [
StackedService.routeObserver,
],
));
}
}
I got this error yesterday. I added it to the pubspec.yaml wrote the following lines and it worked for me
link - https://github.com/flutter/cocoon/pull/2405 (go to the section "Files changed")