Tai*_*aio 1 flutter flutter-layout
class NewBar extends StatelessWidget{
final MainAxisAlignment alignment;
final List<Widget> children;
final MainAxisSize mainAxisSize;
const NewBar({
Key key,
this.alignment: MainAxisAlignment.end,
this.mainAxisSize: MainAxisSize.max,
this.children: const <Widget>[],
}) : super(key: key);
@override
Widget build(BuildContext context) {
final double paddingUnit = ButtonTheme.of(context).padding.horizontal /
4.0;
return new Padding(
padding: new EdgeInsets.symmetric(
vertical: 2.0 * paddingUnit,
horizontal: paddingUnit
),
child: new Row(
mainAxisAlignment: alignment,
mainAxisSize: mainAxisSize,
children: children.map<Widget>((Widget child) {
return new Padding(
padding: new EdgeInsets.symmetric(horizontal: paddingUnit),
child: child
);
}).toList()
)
);
}
}
Run Code Online (Sandbox Code Playgroud)
这只是按钮栏的一些代码。它虽然不显示任何内容。也许我将课程放置在错误的位置,或者我应该将某些内容退还给主应用程序。是新来的。有任何想法吗?
您可以使用ButtonBar多子布局小部件。
例:
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: 'title',
home: new MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new ButtonBar(
mainAxisSize: MainAxisSize.min, // this will take space as minimum as posible(to center)
children: <Widget>[
new RaisedButton(
child: new Text('Hello'),
onPressed: null,
),
new RaisedButton(
child: new Text('Hi'),
onPressed: null,
),
],
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
| 归档时间: |
|
| 查看次数: |
8052 次 |
| 最近记录: |