Newer
Older
flutterBaseApp / lib / ui / widgets / common / button / large_button_widget.dart
StephanieGitHub on 9 Feb 2021 2 KB first commit
import 'package:base_app/res/index.dart';
import 'package:base_app/utils/utils.dart';
import 'package:flutter/material.dart';

/// 功能模块按钮
class LargeButton extends StatelessWidget {
  const LargeButton({
    Key key,
    this.width,
    this.height,
    this.margin,
    this.radius,
    this.bgColor,
    this.highlightColor,
    this.splashColor,
    this.child,
    this.iconPath,
    this.text,
    this.style,
    this.onTap,
  }) : super(key: key);

  final double width; // 宽度
  final double height; // 高度

  /// Empty space to surround the [decoration] and [child].
  final EdgeInsetsGeometry margin; // 外边距

  final double radius; // 圆角
  final Color bgColor; // 背景颜色
  final Color highlightColor; // 点击后的颜色
  final Color splashColor; // 闪烁颜色

  final Widget child; // 子元素

  final String text; // 显示文字
  final String iconPath; // 图标路径
  final TextStyle style; // 文字样式

  final VoidCallback onTap; // 点击后的回调

  @override
  Widget build(BuildContext context) {
    return new Container(
        height: height ?? 120,
        margin:
            const EdgeInsets.only(left: 20.0, right: 20, top: 10, bottom: 10),
        decoration: new BoxDecoration(
          boxShadow: [
            BoxShadow(
                color: Colours.divider,
                offset: Offset(1.0, 2.0),
                blurRadius: 5.0,
                spreadRadius: 2.0),
            BoxShadow(color: Colors.white, offset: Offset(1.0, 1.0)),
          ],
          borderRadius: new BorderRadius.all(new Radius.circular(8.0)),
        ),
        child: RaisedButton(
            color: Colors.white,
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(6.0)),
            onPressed: onTap,
            child: new Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                // logo
                iconPath == null || iconPath == ""
                    ? new Container()
                    : new Image.asset(
                        Utils.getImgPath(iconPath),
                        width: 25.0,
                        height: 25.0,
                        fit: BoxFit.fitHeight,
                      ),
                new Container(
                    margin: const EdgeInsets.only(left: 8.0),
                    alignment: Alignment.center,
                    child: new Center(
                      child: new Text(
                        this.text,
                        style: new TextStyle(
                            fontWeight: FontWeight.bold, fontSize: 20.0),
                      ),
                    ))
              ],
            )));
  }
}