最佳答案
您想使用Flexible
小部件:
import 'package:flutter/material.dart';
void main() {
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: Scaffold(
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Flexible(
flex: 3, // 30%
child: Container(
color: Colors.green,
height: 20,
),
),
Flexible(
flex: 2, // 20%
child: Container(
color: Colors.yellow,
height: 20,
),
),
Flexible(
flex: 5, // 50%
child: Container(
color: Colors.cyan,
height: 20,
),
),
],
),
],
)),
),
);
}
}
看起来像这样:关于flutter - 在Flutter中创建类似于github语言栏的栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64098967/