Created
February 16, 2020 09:46
-
-
Save ryanlid/76b53d6ffd6b1708f81de14c97cd5304 to your computer and use it in GitHub Desktop.
Baseline 基准线布局
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp( | |
MaterialApp( | |
title: "Baseline基准线布局示例", | |
home: LayoutDemo(), | |
), | |
); | |
} | |
class LayoutDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Baseline基准线布局示例"), | |
), | |
body: Row( | |
// 水平等间距排列子组件 | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
// 设置基准线 | |
Baseline( | |
baseline: 80.0, | |
// 对齐自负底部水平线 | |
baselineType: TextBaseline.alphabetic, | |
child: Text( | |
"AaBbCc", | |
style: TextStyle( | |
fontSize: 18.0, | |
textBaseline: TextBaseline.alphabetic, | |
), | |
), | |
), | |
Baseline( | |
baseline: 80.0, | |
baselineType: TextBaseline.alphabetic, | |
child: Container( | |
width: 40.0, | |
height: 40.0, | |
color: Colors.green, | |
), | |
), | |
Baseline( | |
baseline: 80.0, | |
baselineType: TextBaseline.alphabetic, | |
child: Text( | |
"DdEeFf", | |
style: TextStyle( | |
fontSize: 26.0, | |
textBaseline: TextBaseline.alphabetic, | |
), | |
), | |
) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment