score:1

Accepted answer

if you want to enter the styles of the specific button that is elevatedbutton and its text, it could be as follows:

sizedbox( // change the button size
   width: 100,
   height: 50,
   child: elevatedbutton(
      style: elevatedbutton.stylefrom( // elevatedbutton styles
          primary: colors.deeppurple,
          padding: edgeinsets.fromltrb(20, 10, 20, 10), // some padding example
          shape: roundedrectangleborder( // border
            borderradius: borderradius.circular(18.0),
            side: borderside(color: colors.red),
          ),
          [...]
       ),
       textstyle: textstyle( // text styles
          color: colors.white,
          fontsize: 18,
          overflow: textoverflow.ellipsis,
          [...]
       ),
       onpressed: () {},
       child: text("lbs"),
   ),
),

score:1

you can try this also

 flatbutton(
            color: colors.deeppurple[600],
            child: const text('lbs'),
              textcolor: colors.white10,
            onpressed: () {},
          );

edited

widget btn() => outlinedbutton(
      child: const text(
        'lbs',
        style: textstyle(color: colors.white),
      ),
      style: outlinedbutton.stylefrom(
        backgroundcolor: colors.deeppurple[600],
      ),
      onpressed: () {},
    );

score:1

use elevatedbutton.stylefrom

like so:

elevatedbutton(
 style: elevatedbutton.stylefrom(
   textstyle: textstyle(color: colors.white),
   primary: colors.purple,
   shape: roundedrectangleborder
     borderradius: borderradius.circular(30),
   ),
 ),
);

use primary to set the button color.

use sizedbox to change the size.

like so:

sizedbox(
 width: 30,
 height: 20,
 child: elevatedbutton(
  style: elevatedbutton.stylefrom(
   textstyle: textstyle(color: colors.white),
   primary: colors.purple,
  ),
 ),
)

if you want the button to take the maximum width, use:

width: double.maxfinite

score:1

try like this

elevatedbutton(
            onpressed: () {},
            child: text('kg',
                   style:textstyle(color:colors.black,fontsize:18),
                        ),
            style: buttonstyle(
              backgroundcolor:
                  materialstateproperty.all<color>(colors.deeppurple),
            ),
          );

Related Query

More Query from same tag