簡體   English   中英

為什么TextTheme不會改變AppBar TextStyle?

[英]why TextTheme doesn't change AppBar TextStyle?

應用截圖

return MaterialApp(
  theme: ThemeData.dark().copyWith(
    textTheme: GoogleFonts.dancingScriptTextTheme(
        Theme.of(context).textTheme,),
),

如您所見,我在 flutter 應用程序中使用了 danceScriptTextTheme。 但是使用這個 textTheme 只會改變應用主體中的 textSytle。 如屏幕截圖所示,AppBar 中的字體不受影響。 如何更改 appBar 的字體? 詳細解釋。

如果要將其應用於 AppBar,則應在 AppBar 自己的 textTheme 上定義文本主題,如下所示:

MaterialApp(
    theme: ThemeData.dark().copyWith(
      textTheme: GoogleFonts.dancingScriptTextTheme(
        Theme.of(context).textTheme,
      ),
    ),
    home: Scaffold(
      appBar: AppBar(
        textTheme: GoogleFonts.dancingScriptTextTheme(
          Theme.of(context).textTheme,
        ),
      ),
    ));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM