Sweep Gradient

190 views
Skip to first unread message

Rakesh Singh

unread,
Mar 29, 2021, 3:23:29 AM3/29/21
to Flutter Development (flutter-dev)
Hey Developers, I was working with Sweep Gradient. Can someone help me set parameters to achieve the following output-
Colors are- 3A42FF and 37BD95
expected.jpg

Suzuki Tomohiro

unread,
Mar 29, 2021, 8:41:14 AM3/29/21
to Rakesh Singh, Flutter Development (flutter-dev)
I don’t touch Sweep Gradient. Can you explain why you cannot make the gradient even if you know the two colors?

On Mon, Mar 29, 2021 at 03:23 Rakesh Singh <rakeshsh...@gmail.com> wrote:
Hey Developers, I was working with Sweep Gradient. Can someone help me set parameters to achieve the following output-
Colors are- 3A42FF and 37BD95

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/ad67790b-1301-4c00-a53d-99988a40fdf9n%40googlegroups.com.

Suzuki Tomohiro

unread,
Mar 30, 2021, 9:47:17 AM3/30/21
to Flutter Development (flutter-dev)
(Please respond to the mailing list)
Can you simplify the UI so that we can focus on the gradient? I believe you don’t need all of the words and multiple elements to ask the question.

Once it’s done:
- Can you share your code?
- Can you show the comparison between the expected and actual UI?
- Can you share the documentation URL of the Sweep Gradient?


On Tue, Mar 30, 2021 at 09:27 Rakesh Singh <rakeshsh...@gmail.com> wrote:
Actually I want it to start from -90 degree but it is starting from 0degree. Check the attachment below-
P.S. I tried changing startAngle and endAngle but I was unable to obtain the desired output.
sweep.jpg

Suzuki Tomohiro

unread,
Mar 30, 2021, 11:53:55 PM3/30/21
to Flutter Development (flutter-dev)
(Please respond to the mailing list.)

Nice. Try the transform property.

> For example, a SweepGradient normally starts its gradation at 3 o'clock and draws clockwise. To have the sweep appear to start at 6 o'clock, supply a GradientRotation of pi/4 radians (i.e. 45 degrees).


On Tue, Mar 30, 2021 at 3:27 PM Rakesh Singh <rakeshsh...@gmail.com> wrote:

On Wed, Mar 31, 2021 at 12:55 AM Rakesh Singh <rakeshsh...@gmail.com> wrote:
The Code-

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.light(),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
    height:200,
      width:400,
    decoration:BoxDecoration(gradient: SweepGradient(colors:[Color(0xff3A42FF),
                                                             Color(0xff37BD95)
                                                            ]
                                                    )
                            )
    );
  }
}

Expected Output-
image.png

Code Output-
image.png



Reply all
Reply to author
Forward
0 new messages