我想在容器内设置宽度和高度固定的按钮。但是,由于某种原因,按钮占用了Container的高度和宽度。我尝试使用SizedBox
,ButtonTheme
但它们也无法正常工作。
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
debugPaintSizeEnabled = true;
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
// home: EditorScreen(),
home: Scaffold(
body: SafeArea(
child: Container(
height: 65,
width: double.infinity,
color: Colors.black,
child: SizedBox(
height: 50,
width: 50,
child: ButtonTheme(
minWidth: 50,
height: 50,
child: FlatButton(
onPressed: () {},
color: Colors.red,
child: Text("Test"),
),
),
),
),
),
),
);
}
}
指定父容器alignment
属性。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句