2025-01-23 21:51:27 +08:00

46 lines
1.1 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
class ButtonWidget extends StatelessWidget {
const ButtonWidget({
Key? key,
this.text,
this.width,
this.height,
this.radius,
this.onPressed,
}) : super(key: key);
final String? text;
final double? width;
final double? height;
final double? radius;
final void Function()? onPressed;
@override
Widget build(BuildContext context) {
//套一层Container可以做很多事比如设置尺寸
return ElevatedButton(
onPressed: onPressed,
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
//设置最小值为0是的尺寸为children尺寸
minimumSize: MaterialStateProperty.all(Size(
width ?? double.infinity,
height ?? double.infinity,
)),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius?? 32),
),
),
),
child: Text(text ?? "",
style: const TextStyle(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.w300,
)),
);
}
}