我有一个包含行的容器,我正在尝试按分数调整其中的两个容器的大小。我尝试使用,FractionalSizedBox
但输出实际上不是它。
Container(
padding: EdgeInserts.all(10.0),
height: 200,
decoration: BoxDecoration(
border: Border.all(color: Colors.redAccent, width: 1.0),
),
child: Row(
children: [
Flexible(
child: FractionallySizedBox(
heightFactor: 1, widthFactor: 0.5,
child: Container(color: Colors.orange),
),
),
Flexible(
child: FractionallySizedBox(
heightFactor: 1, widthFactor: 1.5,
child: Container(color: Colors.blue)
)
),
],
)
)
您可以在DartPad上运行它。
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
MyApp({Key key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(children: [
Expanded(
flex: 1,
child: Container(color: Colors.redAccent, child: Text("%25"))),
Expanded(
flex: 3,
child: Container(color: Colors.greenAccent, child: Text("%75"))),
]));
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句