簡體   English   中英

此屬性已棄用,請改用 [toolbarTextStyle] 和 [titleTextStyle]

[英]This property is deprecated, please use [toolbarTextStyle] and [titleTextStyle] instead


import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class MyTheme {
  static ThemeData lightTheme(BuildContext context) => ThemeData(
      primarySwatch: Colors.deepPurple,
      fontFamily: GoogleFonts.lato().fontFamily,
      appBarTheme: const AppBarTheme(
        color: Colors.white,
        elevation: 0.0,
        iconTheme: IconThemeData(color: Colors.black),
//textTheme is deprecated
     textTheme: Theme.of(context).textTheme,
      )
      );

  static ThemeData darkTheme(BuildContext context) => ThemeData(
    brightness: Brightness.dark,
  );
}

錯誤:

'textTheme' is deprecated and shouldn't be used. This property is no longer used, please use toolbarTextStyle and titleTextStyle instead.





 "textTheme: Theme.of(context).textTheme,"

我正在為此嘗試一種新的解決方法,但似乎沒有用。

 //  titleTextStyle: TextStyle((context).textTheme),"

嘗試這個:

    import 'package:flutter/material.dart';
    import 'package:google_fonts/google_fonts.dart';

    class MyTheme {
    static ThemeData lightTheme(BuildContext context) => ThemeData(
      primarySwatch: Colors.deepPurple,
      fontFamily: GoogleFonts.lato().fontFamily,
      appBarTheme: const AppBarTheme(
        color: Colors.white,
        elevation: 0.0,
        iconTheme: IconThemeData(color: Colors.black),
        toolbarTextStyle: Theme.of(context).textTheme.bodyText2,
        titleTextStyle: Theme.of(context).textTheme.headline6,
      ));

     static ThemeData darkTheme(BuildContext context) => ThemeData(
        brightness: Brightness.dark,
      );
  }

暫無
暫無

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

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