bravekingzhang / flutter_chat_box

Flutter开发的和ChatGPT聊天的App,全平台支持
Other
609 stars 140 forks source link

项目没法跑起来,依赖的版本可能是不对的? #27

Open sheng-di opened 8 months ago

sheng-di commented 8 months ago
  1. 克隆了仓库
  2. 执行了:
    flutter pub get

    但是发现执行完毕后,pubspec.lock 文件发生了变更,并且 lib/components/markdown.dart 文件中也提示某些属性不受支持: 2.1 执行 flutter pub get 后文件的变更:

    
    (base) ➜  flutter_chat_box git:(main) ✗ git status
    On branch main
    Your branch is up to date with 'origin/main'.

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: macos/Flutter/GeneratedPluginRegistrant.swift modified: pubspec.lock

2.2 markdown.dart 中提示的不支持的属性:

[{ "resource": "/Users/sheng/Documents/code/js/github/flutter_chat_box/lib/components/markdown.dart", "owner": "_generated_diagnostic_collectionname#0", "code": { "value": "undefined_named_parameter", "target": { "$mid": 1, "path": "/diagnostics/undefined_named_parameter", "scheme": "https", "authority": "dart.dev" } }, "severity": 8, "message": "The named parameter 'inlineSyntaxes' isn't defined.\nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'inlineSyntaxes'.", "source": "dart", "startLineNumber": 23, "startColumn": 15, "endLineNumber": 23, "endColumn": 29 },{ "resource": "/Users/sheng/Documents/code/js/github/flutter_chat_box/lib/components/markdown.dart", "owner": "_generated_diagnostic_collectionname#0", "code": { "value": "undefined_named_parameter", "target": { "$mid": 1, "path": "/diagnostics/undefined_named_parameter", "scheme": "https", "authority": "dart.dev" } }, "severity": 8, "message": "The named parameter 'config' isn't defined.\nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'config'.", "source": "dart", "startLineNumber": 25, "startColumn": 15, "endLineNumber": 25, "endColumn": 21 },{ "resource": "/Users/sheng/Documents/code/js/github/flutter_chat_box/lib/components/markdown.dart", "owner": "_generated_diagnostic_collectionname#0", "code": { "value": "argument_type_not_assignable", "target": { "$mid": 1, "path": "/diagnostics/argument_type_not_assignable", "scheme": "https", "authority": "dart.dev" } }, "severity": 8, "message": "The argument type 'CodeWrapperWidget Function(dynamic, dynamic)' can't be assigned to the parameter type 'Widget Function(Widget, String, String)?'. ", "source": "dart", "startLineNumber": 27, "startColumn": 58, "endLineNumber": 27, "endColumn": 69 },{ "resource": "/Users/sheng/Documents/code/js/github/flutter_chat_box/lib/components/markdown.dart", "owner": "_generated_diagnostic_collectionname#0", "code": { "value": "argument_type_not_assignable", "target": { "$mid": 1, "path": "/diagnostics/argument_type_not_assignable", "scheme": "https", "authority": "dart.dev" } }, "severity": 8, "message": "The argument type 'CodeWrapperWidget Function(dynamic, dynamic)' can't be assigned to the parameter type 'Widget Function(Widget, String, String)?'. ", "source": "dart", "startLineNumber": 28, "startColumn": 55, "endLineNumber": 28, "endColumn": 66 }]


![Uploading image.png…]()
sheng-di commented 8 months ago

修改了一下 makrdown:

import 'package:flutter/material.dart';
import 'package:flutter_chatgpt/components/code_wrapper.dart';
import 'package:flutter_chatgpt/components/latex.dart';
import 'package:markdown_widget/markdown_widget.dart';

class Markdown extends StatelessWidget {
  final String text;
  const Markdown({super.key, required this.text});

  @override
  Widget build(BuildContext context) {
    final isDark = Theme.of(context).brightness == Brightness.dark;
    final config =
        isDark ? MarkdownConfig.darkConfig : MarkdownConfig.defaultConfig;

    CodeWrapperWidget codeWrapper(Widget child, String text, String language) {
      return CodeWrapperWidget(child: child, text: text);
    }

    return SelectionArea(
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: MarkdownGenerator(
              inlineSyntaxList: [LatexSyntax()],
              generators: [latexGenerator],
            ).buildWidgets(
              text,
              config: config.copy(configs: [
                isDark
                    ? PreConfig.darkConfig.copy(wrapper: codeWrapper)
                    : const PreConfig().copy(wrapper: codeWrapper),
                TableConfig(
                    wrapper: (table) => SingleChildScrollView(
                          scrollDirection: Axis.horizontal,
                          child: table,
                        )),
              ]),
            )),
      ),
    );
  }
}

flutter 层面没报错了,但是 iOS 方面有个报错:

                ^~~~~~
                _
    /* com.apple.actool.document.warnings */
    /Users/user/Documents/code/js/github/flutter_chat_box/ios/Runner/Assets.xcassets:./AppIcon.appiconset/(null)[2d][Icon-App-50x50@1x.png]: warning: The app icon set "AppIcon" has 6 unassigned children.
    /* com.apple.actool.compilation-results */
    /Users/user/Library/Developer/Xcode/DerivedData/Runner-asymfkqmcluhsfegsontmlcpjhem/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/DerivedSources/GeneratedAssetSymbols-Index.plist
    /Users/user/Library/Developer/Xcode/DerivedData/Runner-asymfkqmcluhsfegsontmlcpjhem/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/DerivedSources/GeneratedAssetSymbols.h
    /Users/user/Library/Developer/Xcode/DerivedData/Runner-asymfkqmcluhsfegsontmlcpjhem/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/DerivedSources/GeneratedAssetSymbols.swift

    /* com.apple.actool.document.warnings */
2
    /Users/user/Documents/code/js/github/flutter_chat_box/ios/Runner/Assets.xcassets:./AppIcon.appiconset/(null)[2d][Icon-App-50x50@1x.png]: warning: The app icon set "AppIcon" has 6 unassigned children.
    /* com.apple.actool.document.notices */
    /Users/user/Documents/code/js/github/flutter_chat_box/ios/Runner/Assets.xcassets:./AppIcon.appiconset/[][ipad][76x76][][][1x][][][]: notice: 76x76@1x app icons only apply to iPad apps targeting releases of iOS prior to 10.0.
    /* com.apple.actool.compilation-results */
    /Users/user/Documents/code/js/github/flutter_chat_box/build/ios/Debug-iphonesimulator/Runner.app/AppIcon60x60@2x.png
    /Users/user/Documents/code/js/github/flutter_chat_box/build/ios/Debug-iphonesimulator/Runner.app/AppIcon76x76@2x~ipad.png
    /Users/user/Documents/code/js/github/flutter_chat_box/build/ios/Debug-iphonesimulator/Runner.app/Assets.car
    /Users/user/Library/Developer/Xcode/DerivedData/Runner-asymfkqmcluhsfegsontmlcpjhem/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/assetcatalog_generated_info.plist

    Unhandled exception:
    Null check operator used on a null value
    #0      Context.embedFlutterFrameworks (file:///Users/user/dev/flutter/packages/flutter_tools/bin/xcode_backend.dart:235:68)
    #1      Context.run (file:///Users/user/dev/flutter/packages/flutter_tools/bin/xcode_backend.dart:59:9)
    #2      main (file:///Users/user/dev/flutter/packages/flutter_tools/bin/xcode_backend.dart:17:5)
    #3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
    #4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
    note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
    /Users/user/Documents/code/js/github/flutter_chat_box/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.2.99. (in target 'path_provider_foundation-path_provider_foundation_privacy' from project 'Pods')

Could not build the application for the simulator.
Error launching application on iPhone 14.

Exited (1).
sheng-di commented 8 months ago

运行 MacOS 也不行。。

Launching lib/main.dart on macOS in debug mode...
../../../../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.1/lib/src/widgets/selection/gesture_detector_builder_selectable.dart:38:22: Error: Type 'TapDragUpDetails' not found.
  void onSingleTapUp(TapDragUpDetails details) {
                     ^^^^^^^^^^^^^^^^
../../../../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.1/lib/src/widgets/selection/gesture_detector_builder_selectable.dart:38:22: Error: 'TapDragUpDetails' isn't a type.
  void onSingleTapUp(TapDragUpDetails details) {
                     ^^^^^^^^^^^^^^^^
../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_sub_themes_data.dart:4139:20: Error: Type argument 'FlexAdaptive' doesn't conform to the bound 'Enum?' of the type variable 'T' on 'EnumProperty'.
 - 'FlexAdaptive' is from 'package:flex_color_scheme/src/flex_adaptive.dart' ('../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_adaptive.dart').
 - 'Enum' is from 'dart:core'.
Try changing type arguments so that they conform to the bounds.
    properties.add(EnumProperty<FlexAdaptive>(
                   ^
../../../../../development/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2258:20: Context: This is the type variable whose bound isn't conformed to.
class EnumProperty<T extends Enum?> extends DiagnosticsProperty<T> {
                   ^
../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_sub_themes_data.dart:4141:20: Error: Type argument 'FlexAdaptive' doesn't conform to the bound 'Enum?' of the type variable 'T' on 'EnumProperty'.
 - 'FlexAdaptive' is from 'package:flex_color_scheme/src/flex_adaptive.dart' ('../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_adaptive.dart').
 - 'Enum' is from 'dart:core'.
Try changing type arguments so that they conform to the bounds.
    properties.add(EnumProperty<FlexAdaptive>(
                   ^
../../../../../development/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2258:20: Context: This is the type variable whose bound isn't conformed to.
class EnumProperty<T extends Enum?> extends DiagnosticsProperty<T> {
                   ^
../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_sub_themes_data.dart:4143:20: Error: Type argument 'FlexAdaptive' doesn't conform to the bound 'Enum?' of the type variable 'T' on 'EnumProperty'.
 - 'FlexAdaptive' is from 'package:flex_color_scheme/src/flex_adaptive.dart' ('../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_adaptive.dart').
 - 'Enum' is from 'dart:core'.
Try changing type arguments so that they conform to the bounds.
    properties.add(EnumProperty<FlexAdaptive>(
                   ^
../../../../../development/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2258:20: Context: This is the type variable whose bound isn't conformed to.
class EnumProperty<T extends Enum?> extends DiagnosticsProperty<T> {
                   ^
../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_sub_themes_data.dart:4146:14: Error: Type argument 'FlexAdaptive' doesn't conform to the bound 'Enum?' of the type variable 'T' on 'EnumProperty'.
 - 'FlexAdaptive' is from 'package:flex_color_scheme/src/flex_adaptive.dart' ('../../../../../.pub-cache/hosted/pub.dev/flex_color_scheme-7.1.2/lib/src/flex_adaptive.dart').
 - 'Enum' is from 'dart:core'.
Try changing type arguments so that they conform to the bounds.
        .add(EnumProperty<FlexAdaptive>('adaptiveRadius', adaptiveRadius));
             ^
oyanglun000 commented 3 months ago

我也遇到了你的问题,感谢你修改了 makrdown