首页 > 解决方案 > Flutter 中的神经拟态设计

问题描述

如何在 Flutter 中实现神经拟态设计或 UI

我正在使用这个插件flutter_neumorphic 3.1.0但是得到了这些错误

我究竟做错了什么?

我如何才能在颤振中实现神经拟态设计

    Launching lib\main.dart on sdk gphone x86 in debug mode...
lib\main.dart:1
/C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_neumorphic-3.1.0/lib/src/widget/button.dart:200:14: Error: 'AnimatedScale' is imported from both 'package:flutter/src/widgets/implicit_animations.dart' and 'package:flutter_neumorphic/src/widget/animation/animated_scale.dart'.
      child: AnimatedScale(
             ^^^^^^^^^^^^^
/C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_neumorphic-3.1.0/lib/src/widget/switch.dart:167:20: Error: 'AnimatedScale' is imported from both 'package:flutter/src/widgets/implicit_animations.dart' and 'package:flutter_neumorphic/src/widget/animation/animated_scale.dart'.
            child: AnimatedScale(
                   ^^^^^^^^^^^^^
3

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Admin\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\Admin\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

我确信发生这种情况是因为 AnimatedScale 是从不同的包中调用的。我该如何解决?

标签: flutter

解决方案


图书馆似乎没有问题,进口问题。

 'AnimatedScale' is imported from both 'package:flutter/src/widgets/implicit_animations.dart' and 'package:flutter_neumorphic/src/widget/animation/animated_scale.dart'

如您所见,它显示 AnimatedScale 是从两个库中导入的。除非您指定,否则 Dart 编译器不会知道您要使用哪个 AnimatedScale。

简单的解决方案是

步骤1。

我假设您想在导入库时使用 neumorphic import 'package:flutter_neumorphic/src/widget/animation/animated_scale.dart' as nmAnimatedScale

第2步。

无论您在哪里使用 AnimatedScale 将其替换为nmAnimatedScale.AnimatedScale( ......)


推荐阅读