如何在Flutter中设置应用范围的fontSize?

目前我有一个TextStyle如下

const TextStyle myTextStyle = TextStyle(fontSize: 18);

但是我必须为每个Text()小部件手动设置它。

最佳答案

看这里:https://flutter.dev/docs/cookbook/design/themes

MaterialApp(
  title: title,
  theme: ThemeData(
    // Define the default brightness and colors.
    brightness: Brightness.dark,
    primaryColor: Colors.lightBlue[800],
    accentColor: Colors.cyan[600],

    // Define the default font family.
    fontFamily: 'Georgia',

    // Define the default TextTheme. Use this to specify the default
    // text styling for headlines, titles, bodies of text, and more.
    textTheme: TextTheme(
      headline1: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
      headline6: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
      bodyText2: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
    ),
  )
);

关于user-interface - 如何在Flutter中为文本元素设置应用范围的fontSize?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61797832/

10-11 15:57