diegoveloper / flutter_percent_indicator

Flutter percent indicator library
BSD 2-Clause "Simplified" License
677 stars 206 forks source link

How to fit in Grid Layout using Expanded widget #186

Closed surajpunemaha closed 1 year ago

surajpunemaha commented 1 year ago

Hello, I want to fit CircularPercentIndicator under GridView.builder list item.

Below is my Sample code and output.

_buildLeaveDetailsGrid()
  {
    var _leaveDetailsList = GridView.builder(
      shrinkWrap: true,
      itemCount: listLeaveBalance.length,
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 2,
          crossAxisSpacing: 1,
          mainAxisSpacing: 1,
          //mainAxisExtent: 260,
          childAspectRatio: 0.80
      ),
      itemBuilder: (context, index)
      {
        return Card(
          margin: const EdgeInsets.all(3),
          elevation: 2,
          clipBehavior: Clip.hardEdge,
          shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(15.0),
          ),
          child: Column(
            children: [
              Container(
                padding: const EdgeInsets.all(5),
                child: getListHeaderText(listLeaveBalance[index].leaveTitle, Colors.black, textAlign: TextAlign.center),
              ),
              Expanded(
                child: Container(
                  child: CircularPercentIndicator(
                    radius: 60.0,
                    circularStrokeCap: CircularStrokeCap.round,
                    lineWidth: 10.0,
                    percent: 0.5,
                    animation: true,
                    center: new Text("100%"),
                    progressColor: Colors.green,
                  ),
                ),
              ),
              GestureDetector(
                child: Container(
                  child: Container(
                    width: double.infinity,
                    color: primaryColor,
                    padding: const EdgeInsets.all(10),
                    child: getH3NormalText(Strings.apply, Colors.white, textAlign: TextAlign.center),
                  ),
                ),
                onTap: ()
                {

                },
              ),
            ],
          ),
        );
      },
    );

    return _leaveDetailsList;
  }

Screenshot_1670827750

diegoveloper commented 1 year ago

Remove the Expanded Widget

On Mon, Dec 12, 2022, 1:54 AM surajpunemaha @.***> wrote:

Hello, I want to fit CircularPercentIndicator under GridView.builder list item.

Below is my Sample code and output.

_buildLeaveDetailsGrid() { var _leaveDetailsList = GridView.builder( shrinkWrap: true, itemCount: listLeaveBalance.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 1, mainAxisSpacing: 1, //mainAxisExtent: 260, childAspectRatio: 0.80 ), itemBuilder: (context, index) { return Card( margin: const EdgeInsets.all(3), elevation: 2, clipBehavior: Clip.hardEdge, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), child: Column( children: [ Container( padding: const EdgeInsets.all(5), child: getListHeaderText(listLeaveBalance[index].leaveTitle, Colors.black, textAlign: TextAlign.center), ), Expanded( child: Container( child: CircularPercentIndicator( radius: 60.0, circularStrokeCap: CircularStrokeCap.round, lineWidth: 10.0, percent: 0.5, animation: true, center: new Text("100%"), progressColor: Colors.green, ), ), ), GestureDetector( child: Container( child: Container( width: double.infinity, color: primaryColor, padding: const EdgeInsets.all(10), child: getH3NormalText(Strings.apply, Colors.white, textAlign: TextAlign.center), ), ), onTap: () {

            },
          ),
        ],
      ),
    );
  },
);

return _leaveDetailsList;

}

— Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/186, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFL3UAZMHAGK7MMY2NSAQTWM3D3VANCNFSM6AAAAAAS3R2RYU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

surajpunemaha commented 1 year ago

Thanks for your reply

I removed Expanded widget and set radius: 45.0 to CircularPercentIndicator

It looks fine on Normal screen, but on Tab it left too much space around. Please see below screenshots of Mobile screen and tab screen respectively.

ss_on_mobile

ss_on_tab

How can I manage it to fit it on any screen.

diegoveloper commented 1 year ago

Read more about response design

On Tue, Dec 13, 2022, 8:41 AM surajpunemaha @.***> wrote:

Thanks for your reply

I removed Expanded widget and set radius: 45.0 to CircularPercentIndicator

It looks fine on Normal screen, but on Tab it left too much space around. Please see below screenshots of Mobile screen and tab screen respectively.

[image: Screenshot_1670827750] https://user-images.githubusercontent.com/31791495/207339961-76ca4609-a2e8-46e3-9640-65ed055b338a.png

[image: ss_on_tab] https://user-images.githubusercontent.com/31791495/207340094-f77e4a70-c335-4583-be1f-48dadbbd6247.jpeg

— Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/186#issuecomment-1348588238, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFL3UBISMUNGN64CNVHIKLWNB4J3ANCNFSM6AAAAAAS3R2RYU . You are receiving this because you commented.Message ID: @.***>

surajpunemaha commented 1 year ago

Okay. Thanks for your help.