Skip to content

ShapeDecoration lerp from gradient to color assert error #93953

Description

@AlexeyKatsuro

Hi, I faced with a problem of animated transition between ShapeDecoration with color and ShapeDecoration with gradient. I also noted that there is no such problem for BoxDecoration.

Steps to Reproduce

  1. Execute flutter run on the code sample

Expected results: Animated transition from gradient to color

Actual results: Gradient -> error during transition -> color.

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(App());
}

class App extends StatelessWidget {
  App({Key? key}) : super(key: key);

  final Decoration _decorationGradient = ShapeDecoration(
      gradient: LinearGradient(colors: [
        Colors.blue,
        Colors.blue.shade800,
      ]),
      shape: RoundedRectangleBorder());

  final Decoration _decorationColor = ShapeDecoration(
    color: Colors.white,
    shape: RoundedRectangleBorder(),
  );

  @override
  Widget build(BuildContext context) {
    return TweenAnimationBuilder<Decoration>(
      tween: DecorationTween(begin: _decorationGradient, end: _decorationColor),
      duration: Duration(seconds: 3),
      builder: (context, value, _) {
        return Container(decoration: value);
      },
    );
  }
}
Logs
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building TweenAnimationBuilder<Decoration>(duration: 3000ms,
dirty, state: _TweenAnimationBuilderState<Decoration>#0cfd8(ticker active)):
'package:flutter/src/painting/shape_decoration.dart': Failed assertion: line 80 pos 15: '!(color !=
null && gradient != null)': is not true.
flutter doctor -v
[✓] Flutter (Channel stable, 2.5.1, on macOS 11.5.1 20G80 darwin-x64, locale en-BY)
    • Flutter version 2.5.1 at /Users/Aliaksei_Katsura/fvm/versions/2.5.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffb2ecea52 (9 weeks ago), 2021-09-17 15:26:33 -0400
    • Engine revision b3af521a05
    • Dart version 2.14.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/Aliaksei_Katsura/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    • CocoaPods version 1.10.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] Connected device (3 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • macOS (desktop)                    • macos         • darwin-x64     • macOS 11.5.1 20G80 darwin-x64
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 95.0.4638.69

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkc: crashStack traces logged to the consolefound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions