在Flutter中如何给两个按钮之间添加空格?

10
我是一名有用的助手,可以为您翻译文本。

我在我的应用程序中使用了两个按钮,这些按钮分别在一个方法中使用。但我无法在这两个按钮之间提供足够的空间,请有人帮忙看看。

以下是我的代码:

        child: Center(
          child: Column(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FlutterLogo(size: 150),
              SizedBox(height: 50),
              _signInButton(),
              _signInFbButton()
            ],
          ),
        ),
      ),
    );
  }

  Widget _signInButton() {


    return Container(
      child: OutlineButton(
        splashColor: Colors.grey,
        onPressed: () {
          signInWithGoogle().whenComplete(() {
            Navigator.of(context).push(
              MaterialPageRoute(
                builder: (context) {
                  return FirstScreen();
                },
              ),
            );
          });
        },
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
        highlightElevation: 0,
        borderSide: BorderSide(color: Colors.grey),
        child: Padding(
          padding: const EdgeInsets.fromLTRB(0, 10, 0, 10),
          child: Column(
            children: <Widget>[
              Row(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Image(image: AssetImage("Assets/google_logo.png"), height: 35.0),
                  Padding(
                    padding: const EdgeInsets.only(left: 10),
                    child: Text(
                      'Sign in with Google',
                      style: TextStyle(
                        fontSize: 20,
                        color: Colors.grey,



  }
  Widget _signInFbButton() {


    return Container(
      child: OutlineButton(
        splashColor: Colors.grey,
        onPressed: () {
          signInWithGoogle().whenComplete(() {
            Navigator.of(context).push(
              MaterialPageRoute(
                builder: (context) {
                  return FirstScreen();
                },
              ),
            );
          });
        },
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
        highlightElevation: 0,
        borderSide: BorderSide(color: Colors.grey),
        child: Container(
          child: Padding(

            padding: const EdgeInsets.fromLTRB(0, 10, 0, 10),
            child: Column(
              children: <Widget>[
                Row(
                  mainAxisSize: MainAxisSize.min,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Image(image: AssetImage("Assets/facebook-logo.png"), height: 35.0),
                    Padding(
                      padding: const EdgeInsets.only(left: 10),
                      child: Text(
                        'Sign in with Google',
                        style: TextStyle(
                          fontSize: 20,
                          color: Colors.grey,

这是我正在尝试做的截图,我正在使用Google登录和Facebook登录创建登录页面。

enter image description here

2个回答

9

为什么不试试你已经拥有的?使用SizedBox就可以实现这一点。

_signInButton(),
 SizedBox(height: 16),//<----
_signInFbButton()

4

您可以使用 Padding 包装 _signInFbButton() 小部件,并根据您的要求提供顶部填充。以下是有效代码:

_signInButton(),
              Padding(
              padding: EdgeInsets.only(top: 5),
              child: _signInFbButton())

希望这回答了您的问题。

输入图像描述


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接