我想在Flutter 中创造这样的纽扣. 好的,我知道Text1和Text2必须在Row()中. 我不知道要创建这个对齐,文本1必须居中,文本2必须右对齐.
Image of what I want to create
我的代码
import 'package:flutter/material.dart';
import 'package:streeti/static/static_colors.dart';
class ButtonWithBlue extends StatelessWidget {
const ButtonWithBlue({Key? key, required this.text1, required this.text2})
: super(key: key);
final String text1;
final String text2;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(20)),
child: Container(
height: 75,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white12,
border: Border.all(
color: AppColors.BlueColor,
width: 1.0,
),
),
child: RawMaterialButton(
onPressed: () {},
splashColor: Colors.blue,
child: Stack(
children: [
Positioned(
right: -20,
top: -25,
height: 120,
width: 120,
child: Container(
decoration: ShapeDecoration(
color: AppColors.BlueColor,
shape: const CircleBorder(),
),
),
),
Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
text1,
style: TextStyle(color: Colors.black, fontSize: 18),
),
SizedBox(
width: 8), // Add some space between text1 and text2
Text(
text2,
style: TextStyle(color: Colors.black, fontSize: 18),
),
],
),
),
],
),
),
),
),
);
}
}
如何构建这个按钮,使文本1在中间,文本2在右侧?(如图所示) 正如我所写的,我知道我应该使用Row(),但在本例中我不知道如何使用它. SpaceBettwen+中心?