Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the shape of my elevatedbutton

Tags:

flutter

dart

 
import 'package:flutter/material.dart';

class SignInPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Time Tracker'),
        elevation: 5.0,
      ),
      body: _buildContent(),
      backgroundColor: Colors.amber[50],
    );
  }

  Widget _buildContent() {
    return Padding(
      padding: EdgeInsets.all(16.0),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          Text(
            'Sing in',
            textAlign: TextAlign.center,
            style: TextStyle(
              fontSize: 32.0,
              fontWeight: FontWeight.w600,
            ),
          ),
          SizedBox(height: 8.0),
          ElevatedButton(
            child: Text('Sing in with google'),
            onPressed: () {},
            style: ElevatedButton.styleFrom(
                primary: Colors.purple[200],
                onPrimary: Colors.black87,
                elevation: 6.0,
                shadowColor: Colors.yellow[200],
          ),
        ],
      ),
    );
  }
}

1_ i don't know how to change the shape of my button in this context and i clearly have an error at the end of the last square ], line 41 .please help me to fix it i appreciate your help in advance.

like image 944
delaram Avatar asked Jan 21 '26 04:01

delaram


2 Answers

You can use a Container as a child of the Button or do this:

      ElevatedButton.styleFrom(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(30.0),
        ),
        child: Text(' Elevated Button'),
      ),
like image 187
Yusuf-Uluc Avatar answered Jan 23 '26 21:01

Yusuf-Uluc


You can use the following way:

Inside elevated button,

style: ButtonStyle(
  shape: MaterialStateProperty.all<RoundedRectangleBorder>(
    RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(18.0),
      side: BorderSide(color: Colors.red)
    )
  )
)

Here you can play with borderRadius property to get different shapes.

like image 35
adrsh23 Avatar answered Jan 23 '26 20:01

adrsh23



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!