我已经从 Scafflod 和按钮中清除了 Flutter 示例,并期待我得到相同的内容,但没有标题栏和按钮:
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'My app title',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
@override
Widget build(BuildContext context) {
return new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'You have pushed the button this many times:',
),
new Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
);
}
}
不幸的是,我得到的东西不适合任何大门:
这是什么?怎么变这么大?如何修复?
最佳答案
您可以将文本包装在“ Material ”小部件中。此外,使用“style:”参数解决了这个问题。
Material(
color: Colors.transparent,
child: Text(
"Your Text Here",
style: TextStyle(
fontFamily: 'custom font', // remove this if don't have custom font
fontSize: 20.0, // text size
color: Colors.white, // text color
),
),
)
关于android-emulator - 如何在没有 Flutter 脚手架的情况下在屏幕上获取简单文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51618701/