mapleafgo / clash-for-flutter

Clash的桌面客户端,支持 windows、linux、macos
MIT License
876 stars 132 forks source link

Hover 编译失败 #18

Closed laikee99 closed 1 year ago

laikee99 commented 2 years ago

使用项目原来的依赖会有这个问题:

/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/widgets/widget_module.dart:38:8
: Error: Type 'SingletonBind' not found.
  List<SingletonBind> get instanciatedSingletons =>
       ^^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/widgets/widget_module.dart:43:1
2: Error: Type 'SingletonBind' not found.
      List<SingletonBind<Object>> singletons, Injector injector) {
           ^^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/models/bind.dart:4:7: Error:
The non-abstract class 'Bind' is missing implementations for these members:
 - BindContract.cast
 - BindContract.copyWith
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 Bind<T extends Object> extends BindContract<T> {
      ^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart:53:19: Context:
'BindContract.cast' is defined here.
  BindContract<E> cast<E extends Object>();
                  ^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart:42:19: Context:
'BindContract.copyWith' is defined here.
  BindContract<T> copyWith({
                  ^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/models/bind.dart:46:7: Error:
The non-abstract class 'AsyncBind' is missing implementations for these members:
 - BindContract.cast
 - BindContract.copyWith
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 AsyncBind<T extends Object> extends Bind<Future<T>>
      ^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart:53:19: Context:
'BindContract.cast' is defined here.
  BindContract<E> cast<E extends Object>();
                  ^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart:42:19: Context:
'BindContract.copyWith' is defined here.
  BindContract<T> copyWith({
                  ^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/models/bind.dart:68:7: Error:
The non-abstract class 'BindInject' is missing implementations for these members:
 - BindContract.cast
 - BindContract.copyWith
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 BindInject<T extends Object> extends Bind<T> {
      ^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart:53:19: Context:
'BindContract.cast' is defined here.
  BindContract<E> cast<E extends Object>();
                  ^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart:42:19: Context:
'BindContract.copyWith' is defined here.
  BindContract<T> copyWith({
                  ^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_core-2.0.0/lib/src/di/injector.dart:8:7: Error: The non-abstract
class 'InjectorImpl' is missing implementations for these members:
 - Injector.getBind
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 InjectorImpl<T> extends Injector<T> {
      ^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/injector.dart:11:16: Context:
'Injector.getBind' is defined here.
  BindEntry<B> getBind<B extends Object>();
               ^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/widgets/widget_module.dart:25:6
: Error: The return type of the method 'WidgetModule.getBind' is 'T?', which does not match the return type,
'BindEntry<T>?', of the overridden method, 'BindContextImpl.getBind'.
 - 'BindEntry' is from 'package:modular_interfaces/src/di/bind.dart'
 ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart').
Change to a subtype of 'BindEntry<T>?'.
  T? getBind<T extends Object>(Injector injector) {
     ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_core-2.0.0/lib/src/di/bind_context.dart:48:17: Context: This is
the overridden method ('getBind').
  BindEntry<T>? getBind<T extends Object>(Injector injector) {
                ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_core-2.0.0/lib/src/di/injector.dart:12:16: Error: The return type
of the method 'InjectorImpl.get' is 'BindEntry<B>', which does not match the return type, 'B', of the overridden method,
'Injector.get'.
 - 'BindEntry' is from 'package:modular_interfaces/src/di/bind.dart'
 ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart').
Change to a subtype of 'B'.
  BindEntry<B> get<B extends Object>() {
               ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/injector.dart:8:5: Context: This is
the overridden method ('get').
  B get<B extends Object>();
    ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_core-2.0.0/lib/src/di/injector.dart:129:8: Error: The method
'InjectorImpl.removeBindContext' has fewer named arguments than those of overridden method 'Injector.removeBindContext'.
  void removeBindContext<B extends BindContext>() {
       ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/injector.dart:33:8: Context: This is
the overridden method ('removeBindContext').
  void removeBindContext<T extends BindContext>({Type? type});
       ^
lib/app/app_widget.dart:33:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem(key: Constant.systrayWinKey, title: "显示窗口"),
          ^^^^^^^^
lib/app/app_widget.dart:34:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem.separator(),
          ^^^^^^^^
lib/app/app_widget.dart:35:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem(
          ^^^^^^^^
lib/app/app_widget.dart:40:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem.separator(),
          ^^^^^^^^
lib/app/app_widget.dart:41:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem(key: GoFlutterSystray.quitCallMethod, title: "退出"),
          ^^^^^^^^
lib/app/app_widget.dart:29:18: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
      var menu = MenuItem.main(
                 ^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/modular_base.dart:178:7: Error:
The method 'setDisposeResolver' isn't defined for the class 'ModularBase'.
 - 'ModularBase' is from 'package:flutter_modular/src/presenter/modular_base.dart'
 ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/modular_base.dart').
Try correcting the name to the name of an existing method, or defining a method named 'setDisposeResolver'.
      setDisposeResolver(disposeBindFunction);
      ^^^^^^^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/widgets/modular_app.dart:156:31
: Error: The argument type 'Widget' can't be assigned to the parameter type 'InheritedWidget'.
 - 'Widget' is from 'package:flutter/src/widgets/framework.dart'
 ('/D:/flutter/packages/flutter/lib/src/widgets/framework.dart').
 - 'InheritedWidget' is from 'package:flutter/src/widgets/framework.dart'
 ('/D:/flutter/packages/flutter/lib/src/widgets/framework.dart').
    if (_dirty) notifyClients(widget);
                              ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/widgets/widget_module.dart:26:2
4: Error: A value of type 'BindEntry<T>?' can't be returned from a function with return type 'T?'.
 - 'BindEntry' is from 'package:modular_interfaces/src/di/bind.dart'
 ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/modular_interfaces-2.0.2/lib/src/di/bind.dart').
    return _fakeModule.getBind<T>(injector);
                       ^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_modular-4.5.1+1/lib/src/presenter/widgets/widget_module.dart:43:1
2: Error: 'SingletonBind' isn't a type.
      List<SingletonBind<Object>> singletons, Injector injector) {
           ^^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/easy_sidemenu-0.2.1/lib/src/SideMenuItem.dart:55:20: Warning: Operand of
null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
 ('/D:/flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
                   ^
Target kernel_snapshot failed: Exception
Failed to build bundle.
hover: Flutter build failed: exit status 1

然后对依赖进行了升级: flutter pub upgrade --major-versions

Changed 4 constraints in pubspec.yaml:
  flutter_modular: ^4.5.1+1 -> ^5.0.3
  fhir_yaml: ^0.6.1 -> ^0.9.0
  file_picker: ^4.5.1 -> ^5.2.0+1
  easy_sidemenu: ^0.2.1 -> ^0.4.0

接着是这个报错:

lib/app/app_widget.dart:33:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem(key: Constant.systrayWinKey, title: "显示窗口"),
          ^^^^^^^^
lib/app/app_widget.dart:34:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem.separator(),
          ^^^^^^^^
lib/app/app_widget.dart:35:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem(
          ^^^^^^^^
lib/app/app_widget.dart:40:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem.separator(),
          ^^^^^^^^
lib/app/app_widget.dart:41:11: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
          MenuItem(key: GoFlutterSystray.quitCallMethod, title: "退出"),
          ^^^^^^^^
lib/app/app_widget.dart:29:18: Error: 'MenuItem' is imported from both
'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:go_flutter_systray/model/menu_item.dart'.
      var menu = MenuItem.main(
                 ^^^^^^^^
Target kernel_snapshot failed: Exception
Failed to build bundle.
hover: Flutter build failed: exit status 1

app_widget.dart的引用稍作修改 : import 'package:go_flutter_systray/model/menu_item.dart' as mi; mi.MenuItem

编译不报错,编译完直接闪退: hover: App 'clash_for_flutter' exited with error: exit status 0xc0000005

请问是啥原因,是我的版本问题吗?

hover doctor:

hover: Hover version v0.47.2 running on windows
hover: Sharing packaging tools
hover: darwin-bundle is supported
hover: Packaging darwin-dmg is not supported on windows
hover: To still package darwin-dmg on windows you need to run hover with the `--docker` flag.
hover: Packaging darwin-pkg is not supported on windows
hover: To still package darwin-pkg on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-appimage is not supported on windows
hover: To still package linux-appimage on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-deb is not supported on windows
hover: To still package linux-deb on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-pkg is not supported on windows
hover: To still package linux-pkg on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-rpm is not supported on windows
hover: To still package linux-rpm on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-snap is not supported on windows
hover: To still package linux-snap on windows you need to run hover with the `--docker` flag.
hover: To package windows-msi these tools are required: candle
hover: Install the WiX Toolset from https://wixtoolset.org/releases/
hover: To still package windows-msi without the required tools installed you need to run hover with the `--docker` flag.
hover:
hover: Sharing flutter version
Flutter 3.0.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f1875d570e (3 months ago) • 2022-07-13 11:24:16 -0700
Engine • revision e85ea0e79c
Tools • Dart 2.17.6 • DevTools 2.12.2
hover: Flutter engine commit: https://github.com/flutter/engine/commit/e85ea0e79c6d894c120cda4ee8ee10fe6745e187
hover: ⚠ The go-flutter project tries to stay compatible with the beta channel of Flutter.
hover: ⚠     It's advised to use the beta channel: `flutter channel beta`
hover: Finding out the C compiler version
gcc (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

hover: Sharing the content of go.mod
module plugin_tutorial/go

go 1.19

require (
        github.com/go-flutter-desktop/go-flutter v0.52.2
        github.com/go-flutter-desktop/plugins/go-plugin-example/battery v0.0.0-00010101000000-000000000000
        github.com/go-flutter-desktop/plugins/go-plugin-example/complex v0.0.0-00010101000000-000000000000
        github.com/pkg/errors v0.9.1
)

require (
        github.com/Xuanwo/go-locale v1.1.0 // indirect
        github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
        github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect
        golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
        golang.org/x/text v0.3.7 // indirect
)

replace github.com/go-flutter-desktop/plugins/go-plugin-example/battery => ../go-plugin-example/battery

replace github.com/go-flutter-desktop/plugins/go-plugin-example/complex => ../go-plugin-example/complex
hover: Sharing the content of hover.yaml
application-name: ""
executable-name: ""
package-name: ""
organization-name: ""
license: ""
target: lib/main_desktop.dart
branch: ""
cache-path: ""
opengl: ""
engine-version: ""
hover: Sharing the content of go/cmd
go\cmd\main.go  go\cmd\options.go

谢谢大佬!

mapleafgo commented 2 years ago

应该是新版本兼容问题吧,你对依赖的升级,直接升了个大版本,我抽时间升个级吧。

laikee99 commented 2 years ago

应该是新版本兼容问题吧,你对依赖的升级,直接升了个大版本,我抽时间升个级吧。

谢谢大佬,麻烦您了

mapleafgo commented 2 years ago

应该是新版本兼容问题吧,你对依赖的升级,直接升了个大版本,我抽时间升个级吧。

谢谢大佬,麻烦您了

客气了😉

Tiny1213 commented 2 years ago

请问这个修复了吗?我也碰到同样的问题

mapleafgo commented 2 years ago

请问这个修复了吗?我也碰到同样的问题

还没有,正在计划用Flutter官方方案重写

Tiny1213 commented 2 years ago

flutter 切回了2.10 好了

mapleafgo commented 1 year ago

最新的已经全面迁移到了官方Flutter了