我是新来的颤振和尝试的东西。
我用 Center Widget 替换了 Scaffold Widget(只是搞砸了)。所有文本都有一个黄色下划线,为了克服这个我用TextDecoration
Text(
friend.name,
style: TextStyle(
decoration: TextDecoration.none
),
));
但这是所有文本小部件所必需的,因此我尝试通过在根 MaterialApp 中设置主题数据来为所有文本小部件通用设置它。
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Friends List',
theme: ThemeData(
primaryColor: Colors.black,
primarySwatch: Colors.teal,
primaryTextTheme: TextTheme(
headline1: TextStyle(color: Colors.green, decoration: TextDecoration.none),
headline2: TextStyle(color: Colors.green, decoration: TextDecoration.none),
headline3: TextStyle(color: Colors.green, decoration: TextDecoration.none),
headline4: TextStyle(color: Colors.green, decoration: TextDecoration.none),
headline5: TextStyle(color: Colors.green, decoration: TextDecoration.none),
headline6: TextStyle(color: Colors.green, decoration: TextDecoration.none),
bodyText1: TextStyle(color: Colors.green, decoration: TextDecoration.none),
bodyText2: TextStyle(color: Colors.green, decoration: TextDecoration.none),
),
textTheme: TextTheme(
headline1: TextStyle(decoration: TextDecoration.none),
headline2: TextStyle(decoration: TextDecoration.none),
headline3: TextStyle(decoration: TextDecoration.none),
headline4: TextStyle(decoration: TextDecoration.none),
headline5: TextStyle(decoration: TextDecoration.none),
headline6: TextStyle(decoration: TextDecoration.none),
bodyText1: TextStyle(decoration: TextDecoration.none),
bodyText2: TextStyle(decoration: TextDecoration.none)
),
),
home: MyHomePage(title: 'Friends list'),
);
}
}
但是 Text 小部件仍然作为下划线。我正在尝试的类似于在 css 中为标签设置样式,而不必每次都设置它。
p
{
universal style here
}
我做错什么了吗?颤振中是否有类似的支持。如果我在拧,请纠正我