【问题标题】:can change background image of app for period of time in flutter?可以在一段时间内更改应用程序的背景图像吗?
【发布时间】:2018-10-28 19:28:48
【问题描述】:

我需要为我的应用添加不断变化的背景。给我一个解决方案

代码:

Widget testBGCarousel = new Container(
  child: new Carousel(
    children: [
      new AssetImage('images/a.jpg'),
      new AssetImage('images/b.jpg'),
      new AssetImage('images/sc.jpg'),
     ].map((bgImg) => new Image(image: bgImg, width: 1500.0, height: 1500.0, 
    fit: BoxFit.cover)).toList(),
     displayDuration: const Duration(seconds: 4),
    ),
    );

pubspec.yaml :

dependencies:
 flutter:
 sdk: flutter

   # The following adds the Cupertino Icons font to your application.
   # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.0
  share: ^0.5.3
  flutter_webview_plugin: ^0.2.1+2
  launch_review: ^1.0.1
  carousel: ^0.1.0

错误:

当前的 Dart SDK 版本是 2.1.0-dev.5.0.flutter-a2eb050044。

因为 carousel 0.1.0 需要 SDK 版本 0.1.0

发布失败 (1) 退出代码 1

【问题讨论】:

    标签: android ios dart flutter carousel


    【解决方案1】:

    你必须检查包是否兼容 Dart 2.0,看起来不兼容:https://pub.dartlang.org/packages/carousel

    我检查了打开的问题:https://github.com/gbrvalerio/carousel/issues/11 作者更新了代码,但没有在 pub Flutter packages repository 上发布。

    所以你必须手动添加它,更新你的pubspec.yaml文件

    改变这个:

    carousel: ^0.1.0
    

    到这里:

    carousel:
       git:
         url: git://github.com/gbrvalerio/carousel.git
    

    【讨论】:

    • 感谢您的回答。我会试试看。 @diegovelper 喜欢我的问题 n 个人资料 :)
    • 只需点击我的答案左侧的检查和上箭头
    猜你喜欢
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 2018-10-22
    • 1970-01-01
    相关资源
    最近更新 更多