| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import 'package:flutter/material.dart';
- class GSYFlexButton extends StatelessWidget {
- final String? text;
- final Color? color;
- final Color textColor;
- final VoidCallback? onPress;
- final double fontSize;
- final int maxLines;
- final MainAxisAlignment mainAxisAlignment;
- GSYFlexButton(
- {Key? super.key,
- this.text,
- this.color,
- this.textColor = Colors.black,
- this.onPress,
- this.fontSize = 20.0,
- this.mainAxisAlignment = MainAxisAlignment.center,
- this.maxLines = 1});
- @override
- Widget build(BuildContext context) {
- return ElevatedButton(
- style: ButtonStyle(
- backgroundColor: MaterialStateProperty.all(color),
- shape: MaterialStateProperty.all(
- RoundedRectangleBorder(
- borderRadius:
- BorderRadius.circular(
- 25))),
- padding: MaterialStateProperty.all( const EdgeInsets.only(
- left: 20.0, top: 10.0, right: 20.0, bottom: 10.0))),
- child: Flex(
- mainAxisAlignment: mainAxisAlignment,
- direction: Axis.horizontal,
- children: <Widget>[
- Expanded(
- child: Text(text!,
- style: TextStyle(
- color: textColor, fontSize: fontSize, height: 1,fontWeight: FontWeight.bold,letterSpacing:2),
- textAlign: TextAlign.center,
- maxLines: maxLines,
- overflow: TextOverflow.ellipsis),
- )
- ],
- ),
- onPressed: () {
- this.onPress?.call();
- });
- }
- }
|