123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import 'package:flutter/material.dart';
- import 'package:sport/widgets/misc.dart';
- class PrimaryButton extends StatelessWidget {
- final VoidCallback callback;
- final String content;
- final double width;
- final double height;
- final double fontSize;
- final Widget child;
- final bool shadow;
- final bool bold;
- final Color buttonColor;
- PrimaryButton({
- @required this.callback,
- @required this.content,
- this.child,
- this.width = double.infinity,
- this.height = 44,
- this.fontSize = 28,
- this.shadow = true,
- this.bold = false,
- this.buttonColor,
- });
- @override
- Widget build(BuildContext context) {
- return InkWell(
- onTap: callback,
- borderRadius: BorderRadius.all(Radius.circular(height / 2)),
- child: Container(
- width: width,
- height: height,
- alignment: Alignment.center,
- decoration: callback == null
- ? BoxDecoration(
- color: Color(0xffdcdcdc),
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.all(Radius.circular(height / 2)),
- )
- : shadow
- ? BoxDecoration(
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.all(Radius.circular(height / 2)),
- boxShadow: [
- BoxShadow(
- offset: Offset(0.0, 3),
- blurRadius: 3,
- spreadRadius: 0,
- color: Color(0x82FF9100))
- ],
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: <Color>[Color(0xffFFC400), Color(0xffFFAA00)],
- ),
- )
- : buttonColor != null
- ? BoxDecoration(
- color: buttonColor,
- shape: BoxShape.rectangle,
- borderRadius:
- BorderRadius.all(Radius.circular(height / 2)),
- )
- : BoxDecoration(
- shape: BoxShape.rectangle,
- borderRadius:
- BorderRadius.all(Radius.circular(height / 2)),
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: <Color>[Color(0xffFFC400), Color(0xffFFAA00)],
- ),
- ),
- child: content?.isNotEmpty == true
- ? Text(
- content,
- style: TextStyle(
- color: Colors.white,
- fontSize:
- height > 40 ? callback == null ? 14.0 : 16.0 : 14.0,
- fontWeight: bold ? FontWeight.w600 : FontWeight.normal),
- strutStyle: fixedLine,
- )
- : child,
- ),
- );
- }
- }
|