我试图在 Flutter 的列中实现两个均匀间隔的按钮。在重复小部件两次时,第一个按钮将缩小特定宽度。检查时发现了这个。
我无法确定这个未知宽度的原因。这是供参考的代码。
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text('Findo', style: Theme.of(context).textTheme.subtitle1),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () => {print('pressed')},
child: Text(
'Store Login',
style: Theme.of(context).textTheme.bodyText1,
),
style: ElevatedButton.styleFrom(
padding: const EdgeInsetsDirectional.fromSTEB(
100, 20, 100, 20),
primary: Theme.of(context).primaryColor,
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(50.0)))),
),
ElevatedButton(
onPressed: () => {print('pressed')},
child: Text(
'Customer Login',
style: Theme.of(context).textTheme.bodyText1,
),
style: ElevatedButton.styleFrom(
padding: const EdgeInsetsDirectional.fromSTEB(
100, 20, 100, 20),
primary: Theme.of(context).accentColor,
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(50.0)))),
)
],
)
],
),
),
),
);
}
}