Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 16, 2020 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/76b53d6ffd6b1708f81de14c97cd5304 to your computer and use it in GitHub Desktop.
Save ryanlid/76b53d6ffd6b1708f81de14c97cd5304 to your computer and use it in GitHub Desktop.
Baseline 基准线布局
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