Ad

Can Change Background Image Of App For Period Of Time In Flutter?

- 1 answer

i need to add changing background to my app.offer me a solution

code:

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

error:

The current Dart SDK version is 2.1.0-dev.5.0.flutter-a2eb050044.

Because carousel 0.1.0 requires SDK version <2.0.0 and no versions of carousel match >0.1.0 <0.2.0, carousel ^0.1.0 is forbidden. So, because quiz depends on carousel ^0.1.0, version solving failed.

pub get failed (1) exit code 1

Ad

Answer

You have to check if the package is Dart 2.0 compatible, and looks like it is not : https://pub.dartlang.org/packages/carousel

I checked the issue opened : https://github.com/gbrvalerio/carousel/issues/11 The author updated the code but it was not published on pub Flutter packages repository.

So you have to add it manually, update your pubspec.yaml file

Change this:

carousel: ^0.1.0

To this:

carousel:
   git:
     url: git://github.com/gbrvalerio/carousel.git
Ad
source: stackoverflow.com
Ad