cod*_*ler 4 dart flutter flutter-container
我有一个包含一些文本的容器,当文本处于正常水平位置时,它被分成两行,因为它不适合一行,我理解:
Container(
width: 30,
height: 250,
color: Color.fromRGBO(254, 242, 0, 1),
child: Center(
child: Text(
"dB per H",
style: TextStyle(
fontSize: 12,
color: Colors.black,
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
这将呈现为:
现在我正在旋转文本,以便它在垂直方向上呈现,其中容器有足够的空间。然而,它仍然被分成两行,而预期现在它可以毫无问题地安装。
如何解决这个问题?
Container(
width: 30,
height: 250,
color: Color.fromRGBO(254, 242, 0, 1),
child: Center(
child: Transform.rotate(
angle: -pi / 2,
child: Text(
"dB per H",
style: TextStyle(
fontSize: 12,
color: Colors.black,
),
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
这将呈现为:
小智 5
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Title')),
body: Container(
width: 30,
height: 250,
color: Color.fromRGBO(254, 242, 0, 1),
child: Center(
child: RotatedBox(
quarterTurns: 3,
child: Text(
"dB per H",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: Colors.black,
),
),
),
),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2137 次 |
| 最近记录: |