首页 > 解决方案 > 如何将浮动动作粘贴到底部颤动(底部对齐)

问题描述

我想要一个没有任何填充或任何东西的 FAB 粘在屏幕底部。但还没有看到正确的小部件。我不喜欢使用堆栈。有什么建议么?

标签: flutterdart

解决方案


我像下面这样使用 在此处输入图像描述

 floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
          floatingActionButton: Padding(
            padding: const EdgeInsets.all(12.0),
            child: CustomMaterialButton(
              color: Colors.green,
              icon: Icons.check,
              text: 'Apply',
              onTap: () {},
              iconPosition: IconPosition.LEFT,
            ),
          ),

按钮

Material(
      elevation: 8,
      shadowColor: this.color,
      borderRadius: BorderRadius.circular(4),
      color: this.color,
      child: InkWell(
        highlightColor: Colors.transparent,
        onTap: this.onTap,
        child: Container(
          width: double.infinity,
          height: 48,
          child: Center(
            child: this.iconPosition == IconPosition.LEFT
                ? Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      this.icon != null
                          ? Icon(
                              this.icon,
                              color: Colors.white,
                              semanticLabel: 'a',
                            )
                          : Container(),
                      AutoSizeText(
                        ' ${this.text}',
                        textScaleFactor: 1,
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 18, 
                        fontFamily: 'Muli'),
                      ),
                    ],
                  )
                : Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      AutoSizeText(
                        ' ${this.text}',
                        textScaleFactor: 1,
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 18, 
                        fontFamily: 'Muli'),
                      ),
                      this.icon != null
                          ? Icon(
                              this.icon,
                              semanticLabel: 'a',
                              color: Colors.white,
                            )
                          : Container(),
                    ],
                  ),
          ),
        ),
      ),
    );

推荐阅读