Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter The named parameter 'colors' isn't defined in SweepGradient

Tags:

flutter

in my project i want to use SweepGradient and when i try to use with this definition i get error:

Context: Found this candidate, but the arguments don't match.
  const SweepGradient({
        ^^^^^^^^^^^^^

my code implementations:

static final BoxDecoration _gradientBorderDecoration = BoxDecoration(
  shape: BoxShape.circle,
  // https://brandpalettes.com/instagram-color-codes/
  gradient: SweepGradient(
    colors: [
      Color(0xFF833AB4), // Purple
      Color(0xFFF77737), // Orange
      Color(0xFFE1306C), // Red-pink
      Color(0xFFC13584), // Red-purple
    ],
  ),
);

SweepGradient construct class:

const SweepGradient({
  this.center = Alignment.center,
  this.startAngle = 0.0,
  this.endAngle = math.pi * 2,
  required List<Color> colors,
  List<double>? stops,
  this.tileMode = TileMode.clamp,
  GradientTransform? transform,
}) : assert(center != null),
     assert(startAngle != null),
     assert(endAngle != null),
     assert(tileMode != null),
     super(colors: colors, stops: stops, transform: transform);

flutter version:

Flutter 1.22.0-10.0.pre.153 • channel master • https://github.com/flutter/flutter.git
Framework • revision 2e643651a9 (15 hours ago) • 2020-09-11 23:07:03 -0400
Engine • revision 16b900b63e
Tools • Dart 2.10.0 (build 2.10.0-117.0.dev)
like image 561
DolDurma Avatar asked Sep 12 '20 17:09

DolDurma


People also ask

Why can't I get the color of a named parameter?

The named parameter 'color' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'color'. The named parameter 'color' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'color'.

Why is my named parameter'stops'not defined?

- The named parameter 'stops' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'stops'. - The named parameter 'child' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'child'.

How to fix color parameter is not defined in Dart analysis?

The named parameter 'colors' isn't defined. how can i fix it? Show activity on this post. Try to restart the Analysis Dart Server. Ctrl + Shift + P on Windows, Cmd + Shift + P on Macos opens the command palette if you use VS Code. Then run Dart: Restart Analysis Server.

How to show activity in flutter IDE?

Ctrl + Shift + P on Windows, Cmd + Shift + P on Macos opens the command palette if you use VS Code. Then run Dart: Restart Analysis Server. Show activity on this post. Clean your project by pressing flutter clean command. Close the IDE and restart it. And this issue will be solved Show activity on this post. You can try restarting the IDE.


1 Answers

This happened to me as well after I upgraded to the latest stable flutter version 1.12. I fixed it doing following:

  1. Type in terminal: flutter clean
  2. Under File --> Invalidate Caches / Restart (click this option)

Afterwards everything worked like a charm again.

like image 168
Christian X Avatar answered Sep 18 '22 17:09

Christian X