我正在try 将GraphQL_Ffltter(https://pub.dev/packages/graphql_flutter)用于我的MVVM架构.(https://stacked.filledstacks.com/docs/getting-started/overview)当我try 运行我的代码时,从GraphQL_Ffltter包中收到以下错误
`../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/graphql-5.1.2/lib/src/links/websocket_link/websocket_client.dart:577:7:错误:非抽象类‘GraphQLWebSocketChannel’缺少以下成员的实现:
- WebSocketChannel.ready 试着 Select
- 提供一个实现,
- 从超类或混合继承实现,
- 将类标记为抽象类,或
- 提供"noSuchMethod"实现.
类GraphQLWebSocketChannel扩展StreamChannelMixin<;Dynamic>; ^^ ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-2.3.0/lib/src/channel.dart:56:22:上下文:这里定义了‘WebSocketChannel.Ready’. 最终future <;void>;Ready=Future.Value();`
这是我在main.dart文件中的代码.只要我导入了包,我就会收到错误.
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,
],
));
}
}