gpt4 book ai didi

dart - FlutterLogo 可以拉伸(stretch)填充吗?

转载 作者:行者123 更新时间:2023-12-03 03:26:50 24 4
gpt4 key购买 nike

我想在我的应用程序中显示一个大的 FlutterLogo:
https://docs.flutter.io/flutter/material/FlutterLogo-class.html

为了考虑不同的屏幕尺寸,我想让它拉伸(stretch)填充。那可能吗?还是我需要使用 MediaQuery 来确定父级的大小并将其传递给 FlutterLogo(size:)?

我当前的代码:

  Widget build(BuildContext context) {
return new Center(
child: new FlutterLogo(size: 800.0, style: FlutterLogoStyle.horizontal, textColor: Colors.white),
);
}

最佳答案

您可以使用 ConstrainedBox 来完成此操作。 :

screenshot

import 'package:flutter/material.dart';

void main() {
runApp(new MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
theme: new ThemeData.dark(),
home: new MyHomePage(),
);
}
}

class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Example App')),
body: new ConstrainedBox(
constraints: new BoxConstraints.expand(),
child: new FlutterLogo(
style: FlutterLogoStyle.horizontal,
textColor: Colors.white,
),
),
);
}
}

关于dart - FlutterLogo 可以拉伸(stretch)填充吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46008569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com