[英]Flutter: Yellow Lines Under Text
I understand that I do not have a Scaffolding around my text but I'm brand new to flutter and can't seem to work out how to add scaffolding to my text.我知道我的文本周围没有脚手架,但我是 flutter 的新手,似乎无法弄清楚如何在我的文本中添加脚手架。 My code is below:
我的代码如下:
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.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: 'Test Bench',
home: new Container(
decoration: BoxDecoration(color: Colors.pinkAccent),
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Text(
"Hello, World",
style: TextStyle(
fontSize: 60.0,
fontWeight: FontWeight.bold,
fontFamily: 'Oswald',
color: Colors.black),
),
),
),
);
}
}
You can check by following code.您可以通过以下代码进行检查。 Also refer
另请参阅
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Test Bench',
home: Scaffold(
body: new Container(
decoration: BoxDecoration(color: Colors.pinkAccent),
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Text(
"Hello, World",
style: TextStyle(
fontSize: 60.0,
fontWeight: FontWeight.bold,
fontFamily: 'Oswald',
color: Colors.black),
),
),
),
),
);
}
}
I think you need a explanation for this:我认为您需要对此进行解释:
Always uses Scaffold (generally better) or any other component that provides material theme like a simple Material widget始终使用 Scaffold(通常更好)或任何其他提供材质主题的组件,例如简单的 Material 小部件
We can remove yellow lines by adding the Parent widget as "Material" or use "Scaffold"我们可以通过将 Parent 小部件添加为“Material”或使用“Scaffold”来删除黄线
return MaterialApp( home: Scaffold( body: Container( child: SingleChildScrollView(child: Text('Test')), ), ), ); return MaterialApp(home: Scaffold(body: Container(child: SingleChildScrollView(child: Text('Test')), ), ), );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.