Home > database >  Add Icon to ArgonTimerButton in flutter dart
Add Icon to ArgonTimerButton in flutter dart

Time:07-04

I am using argon_buttons_flutter 1.1.0 package to create a timer button and its working great and all. I just have a question which is can I add an Icon to this button? Like when I use an elevated button or so, I can do it by make it ElevatedButton.icon but it doesnt seem to work with this one which I think is because this is a customized button. Is there a way to add an Icon to it?

here is the code for the button:

ArgonTimerButton(
          initialTimer: 60, // Optional
          height: 50,
          width: MediaQuery.of(context).size.width * 0.45,
          minWidth: MediaQuery.of(context).size.width * 0.30,
          color: Color(0xFF7866FE),
          borderRadius: 5.0,
          child: const Text(
            "Resend Verification Email",
            style: TextStyle(
                color: Colors.black,
                fontSize: 18,
                fontWeight: FontWeight.w700
            ),
          ),
          loader: (timeLeft) {
            return Text(
              "Resend Verification Email in | $timeLeft",
              style: const TextStyle(
                  color: Colors.black,
                  fontSize: 18,
                  fontWeight: FontWeight.w700
              ),
            );
          },
          onTap: (startTimer, btnState) async {
            if (btnState == ButtonState.Idle) {
              await sendVerificationEmail();
              startTimer(60);
            }
          },

        ),

CodePudding user response:

you can add an icon using the Row on the child

ArgonTimerButton(
  initialTimer: 60, // Optional
  height: 50,
  width:
  MediaQuery.of(context).size.width * 0.45,
  minWidth:
  MediaQuery.of(context).size.width * 0.30,
  color: Color(0xFF7866FE),
  borderRadius: 5.0,
  child: Row(
    crossAxisAlignment:
    CrossAxisAlignment.center,
    children: [
      Icon(Icons.add),
      Text(
        "Resend Verification Email",
        style: TextStyle(
            color: Colors.black,
            fontSize: 18,
            fontWeight: FontWeight.w700),
      ),
    ],
  ),
  loader: (timeLeft) {
    return Text(
      "Resend Verification Email in | $timeLeft",
      style: const TextStyle(
          color: Colors.black,
          fontSize: 18,
          fontWeight: FontWeight.w700),
    );
  },
  onTap: (startTimer, btnState) async {
    if (btnState == ButtonState.Idle) {
      await sendVerificationEmail();
      startTimer(60);
    }
  },
),
  • Related