Flutter – Container with ring progress indicator border

Advertisements

I am trying to achieve a container that will have a progress indicator border, like in this image:

I’ve tried to achieve it using a container inside another container (1 container for the outside white border, and one container for the inside blue background with the icon), but I can’t achieve the progress indicator effect.

Does anyone know how can I achieve this?

Thank you

>Solution :

If you don’t want to use a CustomPainter you can try to achieve that with a Stack widget

You can see this example in DartPad

Use the value property on the second CircularProgressIndicator to update the value with setState or any other State Management technique you like

import 'package:flutter/material.dart';

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

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

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

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: const [
        CircleAvatar(
          backgroundColor: Colors.white,
          radius: 24,
          child: Icon(Icons.check),
        ),
        SizedBox(
          width: 50,
          height: 50,
          child: CircularProgressIndicator(
            color: Colors.grey,
            value: 1,
          ),
        ),
        SizedBox(
          width: 50,
          height: 50,
          child: CircularProgressIndicator(
            color: Colors.blue,
            value: .3, // Change this value to update the progress
          ),
        ),
      ],
    );
  }
}

Leave a ReplyCancel reply