首页 > 解决方案 > 不推荐使用 textTheme 颤动的警告

问题描述

我正在使用颤振 2.5。我编写了以下代码,这给了我不推荐使用的**textTheme**属性警告。

return MaterialApp(
      // home: homePage(),
      themeMode: ThemeMode.light,
      theme: ThemeData(
        primarySwatch: Colors.purple,
        fontFamily: GoogleFonts.lato().fontFamily,
        appBarTheme: AppBarTheme(color: Colors.white,
        elevation: 0,
        iconTheme: IconThemeData(color: Colors.black),
        textTheme: Theme.of(context).textTheme
        )
      ),
      darkTheme:
          ThemeData(brightness: Brightness.dark, primarySwatch: Colors.red),
      debugShowCheckedModeBanner: false,
      initialRoute: MyRoutes.homeRoutes,
      routes: {
        "/": (context) => LoginPage(),
        MyRoutes.homeRoutes: (context) => homePage(),
        MyRoutes.loginRoutes: (context) => LoginPage(),
      },
    );

标签: flutter

解决方案


在 Flutter 1.13.8 中,TextTheme 的某些属性已被弃用并更改为另一个名称。也许您正在使用旧的文本样式属性:

您可以在此处找到新属性的列表


推荐阅读