flutter circular progress Widget - flutter

Am looking to implement a circular progress widget in flutter similar to the Jquery circular progress. The idea is when a button is clicked, as an activity happens in the background, the circular progress fills in color while a counter incrementally goes from 0-100%. I am able to do the circular fill using custom paint but am unable to display the actual % count as the color fills the circular progress. How would i do this in flutter?

Use precent_indicator library: https://pub.dev/packages/percent_indicator/install
It has good features, such as showing progress around a picture:
CircularPercentIndicator(
radius: 100.0,
lineWidth: 15.0,
progressColor: Colors.blue,
percent: 0.4,
center: const CircleAvatar(
backgroundImage: NetworkImage('https://tr.web.img4.acsta.net/c_310_420/pictures/bzp/01/61282.jpg'),
radius: 85,
),
),
),

you can use this plugin: https://pub.dartlang.org/packages/flutter_circular_chart
they have the component you need

Related

how to create multiple radial bar inside each other?

I need to make a multiple radial bar inside each other. I searched but only syncfusion_flutter_charts package had some thing like that but I it needs licenses .There is no limitation on using other flutter packages.
the chart is some thing like this multiple radial bar
The best way to do this is to use a Stack widget together with Positioned Widgets. Examples with guides are found in the added links by the Flutter team itself.
What You can do is, use Stack widget to stack the Widgets and use to Wrap those widgets in Positioned widget to Passioned them the way you want inside the Stack.
Although I should mention heavy use of stack widget will have some performance impact.
using this way you can achieve it ( this is only a example , how to do it , it is not a implementation code ) ,
write code according to the use case , that is add alignment ,positioned ,etc...
stack(children: [
CircularPercentIndicator(
radius: 50.0,
circularStrokeCap: CircularStrokeCap.round,
progressColor: Colors.purple,
.....
.....
),
CircularPercentIndicator(
radius: 100.0,
circularStrokeCap: CircularStrokeCap.round,
progressColor: Colors.red,
.....
.....
),
CircularPercentIndicator(
radius: 150.0,
circularStrokeCap: CircularStrokeCap.round,
progressColor: Colors.blue,
.....
.....
),
])
actually I found the best way.CircularPercentIndicator has a center property which takes a widget. I gave it an another CircularPercentIndicator .this way worked perfect

Fade in/out FloatingActionButton?

Is there any way to slowly fade-in and out a floating action button? I have in my list a FAB to offer the user a way to quickly scroll to the top of the list.
So far I've found in various posts how to detect when the list is scrolled to the top or away from the top (https://medium.com/#diegoveloper/flutter-lets-know-the-scrollcontroller-and-scrollnotification-652b2685a4ac), but I fail to find how I can change the alpha value of a widget. Any idea how to solve this?
Thanks
Martin
This example is from flutter dev page:
With a AnimatedOpacity you can fade any widget.
Just put you floating action button as child of AnimatedOpacity.
Here is some example:
AnimatedOpacity(
// If the widget is visible, animate to 0.0 (invisible).
// If the widget is hidden, animate to 1.0 (fully visible).
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 500),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 200.0,
height: 200.0,
color: Colors.green,
),
);
You can find more info and full code here: https://flutter.dev/docs/cookbook/animation/opacity-animation

Flutter Circular Avatar does not support Image from storage

I am looking for one widget which can handle both images(network image and storage image) in a circular shape. I have to select one image from storage if not available on network. I used many widgets and find CircleAvatar best among them. It makes circular shape if you put image in backgroundImage. It needs ImageProvider parameter. How I can to use Image.file(_file) in backgroundImage to pass it as a ImageProvider.
CircleAvatar(
radius: 80.0,
backgroundImage:
// NetworkImage("${imageNotfound}"), // NetowrkImage extends ImageProvider class, so it works
Image.file(_file), // How to convert my Image class to ImageProvider???
backgroundColor: Colors.transparent,
)
Note: My main concern is,use any single widget which have circular shape property for both(network image and storage image).
you can handle it as follows
local asset
CircleAvatar(
radius: 50.0,
backgroundImage: AssetImage("assets/images/image.jpg"),
)
network
CircleAvatar(
radius: 50.0,
backgroundImage: NetworkImage("https://images.unsplash.com/photo-1535083475219-aed59281b9aa?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"),
)

Flutter: adding a gradient to my progress bar

Let me first say I started with flutter last week so I apologise in advance for my lack of knowledge.
I'm using a progress bar in my application:
FAProgressBar(
size: 50,
currentValue: dailyProgress,
direction: Axis.vertical,
verticalDirection: VerticalDirection.up,
progressColor: Colors.amber,
backgroundColor: Colors.grey[300],
animatedDuration: const Duration(milliseconds: 2000),
),
In reality it looks like this: https://imgur.com/NZUoZtW
I want it to look like this: https://imgur.com/gFCqfzR
How would you recommend me to proceed? It seems impossible to replace the progressColor property with a gradient. Is there another package I can use? Any suggestion is appreciated.
I suggest you try Gradient Widgets package for Flutter.
It has GradientProgressIndicator which should fit your needs.

how to change the opacity of the snackbar in flutter?

I wish to change the opacity of the SnackBar. It has only the background property. Can it be customized or I have to create the custom widget for snack bar?
Try using the color property of snack bar like this,
backgroundColor: Colors.black.withOpacity(0.5)
This should work as you expected.
You can adjust the opactiy of your backgroundColor with
color.withAlpha(..),
color.withOpacity(..),
using a hexadecimal integer 0x33ffffff (the first pair of digits after the x represents the alpha value),
creating a Color using Color.fromARGB(...)
or by using Color.fromRGBO(...).
You can find information about this on this documentation page about the Color class.
Now, you face the following problem: Your content is not yet translucent.
This is easily adjustable using the Opcacity Widget.
In your Snackbar just surround your actual content with an Opacity Widget:
SnackBar(backgroundColor: Color(0x66bbbbbb),
content: Opacity(opacity: .7,
child: Container(), // your content
),
)
If you are planning to make the background transparent, this may help you.
Mostly you get a black background because of elevation.
SnackBar(
elevation: 0,
backgroundColor: Colors.transparent,
/.......
),