11
 
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.

delaram
  • 649
  • 4
  • 8
  • 15
  • 2
    https://stackoverflow.com/questions/49991444/create-a-rounded-button-button-with-border-radius-in-flutter – sonic Mar 15 '21 at 17:36

3 Answers3

16

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'),
      ),
Yusuf-Uluc
  • 887
  • 4
  • 15
8

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.

adrsh23
  • 210
  • 2
  • 10
3

Make the child of the ElevatedButton a Container widget.

You can then use the shape attribute available for container widget.

The text widget can become the child for the container widget.

THEODORE
  • 917
  • 10
  • 12