首页 > 解决方案 > 如何改变我的高架按钮的形状

问题描述

 
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_ 在这种情况下,我不知道如何更改按钮的形状,我在最后一个正方形的末尾显然有一个错误],第 41 行。请帮我解决它,我提前感谢您的帮助。

标签: flutterdart

解决方案


您可以使用 Container 作为 Button 的子级,或者执行以下操作:

ElevatedButton.styleFrom(shape: new RoundedRectangleBorder(
           borderRadius: new BorderRadius.circular(30.0),
           ),),
           child: Text(' Elevated Button'))

推荐阅读