1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import 'package:flutter/material.dart';
- ///主要按钮
- class MainButton extends StatelessWidget {
- final void Function() onPressed;
- final String text;
- final bool isOutlined;
- final EdgeInsets? buttonPadding;
- const MainButton(
- {super.key,
- required this.text,
- required this.onPressed,
- this.buttonPadding,
- this.isOutlined = false});
- @override
- Widget build(BuildContext context) {
- return isOutlined
- ? OutlinedButton(
- onPressed: onPressed,
- style: ButtonStyle(
- padding: buttonPadding == null
- ? null
- : WidgetStatePropertyAll(buttonPadding),
- side: WidgetStatePropertyAll(
- BorderSide(color: Color(0xFFD2D2D2)))),
- child: Text(
- text,
- style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
- ))
- : ElevatedButton(
- onPressed: onPressed,
- style: ButtonStyle(
- padding: buttonPadding == null
- ? null
- : WidgetStatePropertyAll(buttonPadding),
- backgroundColor:
- WidgetStatePropertyAll(Theme.of(context).primaryColor),
- elevation: const WidgetStatePropertyAll(0.0)),
- child: Text(
- text,
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Theme.of(context).colorScheme.onPrimary,
- fontWeight: FontWeight.bold),
- ));
- }
- }
|