3
【笔记】Flutter 的 AspectRatio 宽高比组件
source link: https://loli.fj.cn/2023/06/25/Flutter%E7%9A%84AspectRatio%E5%AE%BD%E9%AB%98%E6%AF%94%E7%BB%84%E4%BB%B6/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【笔记】Flutter 的 AspectRatio 宽高比组件
2023-06-25 2023-06-26Flutter 学习指北
Flutter 的 AspectRatio 宽高比组件学习笔记
AspectRatio 宽高比组件
- AspectRation 组件可以设置子元素的宽高比
aspectRatio
:指定容器的宽高比
2
:宽的比例1
:高的比例
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("文本内容"),
),
body: const App(),
),
));
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 2/1,
child: Container(
color: Colors.red,
),
);
}
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK