🔥 ۴۰ درصد تخفیف ثبت‌نام دوره‌ها قبل از افزایش قیمت‌ها
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ استاد کاژیره هدایت
theme.of(context)
خانم عدیله ترکان حل شده توسط خانم عدیله ترکان

سلام 

من وقتی میخوام تو تکستم از text theme استفاده کنم بهم ارور میده

      textTheme: GoogleFonts.latoTextTheme(TextTheme(
          bodyMedium: TextStyle(fontSize: 15),
          bodyLarge: TextStyle(fontSize: 13),
          titleLarge: TextStyle(fontWeight: FontWeight.bold),
          titleMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
        )),

این قسمت themedata و کد text که قسمت style:theme.of(context) رو ارور میده

 const Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      'david efron',
                      style: theme.of(context).textTheme.titleMedium,
                    ),
                    SizedBox(
                      height: 2,
                    ),
                    Text('application developer'),
                    SizedBox(
                      height: 4,
                    ),
                    Row(
                      children: [
                        Icon(CupertinoIcons.location_circle),
                        Text(
                          'amsterdam , netherlands',
                          style: theme.of(context).TextTheme.bodyLarge,
                        ),
                      ],                  

سلام،

1. theme.of(context) باید Theme.of(context) باشد. (T باید بزرگ باشد)
2. برای دسترسی به TextTheme, باید از .textTheme استفاده کنید، نه .TextTheme (t باید کوچک باشد).
در نتیجه، کد شما باید به شکل زیر باشد:

Text(
 'david efron',
 style: Theme.of(context).textTheme.titleMedium,
),
SizedBox(
 height: 2,
),
Text('application developer'),
SizedBox(
 height: 4,
),
Row(
 children: [
   Icon(CupertinoIcons.location_circle),
   Text(
     'amsterdam , netherlands',
     style: Theme.of(context).textTheme.bodyLarge,
   ),
 ],
)
بهترین پاسخ
خانم عدیله ترکان ۰۴ فروردین ۱۴۰۳، ۰۹:۱۰