۱ Babak Hakimimehr
مشکل در استفاده از Theme.of
جامعه فلاتر ایجاد شده در ۰۹ مرداد ۱۴۰۱

استاد سلام

من کدم اینه

ولی ارور میده

کد:

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Circulum Vitae'),
        actions: const [
          Icon(CupertinoIcons.chat_bubble_fill),
          Padding(
            padding: EdgeInsets.fromLTRB(8, 0, 16, 0),
            child: Icon(CupertinoIcons.ellipsis_vertical),
          ),
        ],
      ),
      body: Column(
        children: [
          Padding(
            padding: const EdgeInsets.all(32.0),
            child: Row(
              children: [
                ClipRRect(
                    borderRadius: BorderRadius.circular(8.0),
                    child: Image.asset(
                      'assets/images/profile.jpeg',
                      width: 60,
                      height: 60,
                    )),
                Expanded(
                  child: Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        const Text(
                          'Brice seraphin',
                          style: Theme.of(context).textTheme.subtitle1,
                        ),
                        const Text('Product & Print Designer'),
                        Row(
                          children: [
                            Icon(CupertinoIcons.location),
                            Text('paris, France'),
                          ],
                        )
                      ],
                    ),
                  ),
                ),
                Icon(
                  CupertinoIcons.heart,
                  color: Theme.of(context).primaryColor,
                )
              ],
            ),
          ),
          Padding(
            padding: const EdgeInsets.fromLTRB(32, 0, 32, 16),
            child: Text(
                'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse fermentum non tortor sodales rhoncus. Ut ipsum sapien, interdum laoreet ante vitae, vestibulum viverra est.'),
          ),
          Divider()
        ],
      ),
    );
  }
}

اروری که میده:

: Error: Not a constant expression.
lib/main.dart:83
                          style: Theme.of(context).textTheme.subtitle1,
                                                   ^^^^^^^^^

اطلاعات theme :

      theme: ThemeData(
        primarySwatch: Colors.blue,
        primaryColor: Colors.pink.shade400,
        brightness: Brightness.dark,
        scaffoldBackgroundColor: Color.fromARGB(255, 30, 30, 30),
        textTheme: GoogleFonts.latoTextTheme(TextTheme(
          bodyText2: TextStyle(fontSize: 15),
          bodyText1: TextStyle(fontSize: 13),
          headline6: TextStyle(fontWeight: FontWeight.bold),
          subtitle1: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
        )),
        appBarTheme: const AppBarTheme(
          backgroundColor: Colors.black,
        ),
      ),

میشه راهنمایی کنید

سلام وقت بخیر

من بررسی کردم اما در اطلاعاتی که دادین مشکلی نمیبینم.

داخل vscode روی خط مورد نظر اروری نمایش داده نمیشه؟

متین عفتی ۱۴ مرداد ۱۴۰۱، ۰۹:۲۷