[英]kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead
[英]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.