Reputation: 47
I used this code line elsewhere but it does not give an error
AutoSizeText(
"عنوان"
,maxLines: 1
,overflow: TextOverflow.ellipsis,
minFontSize: 10,
style:GoogleFonts.rubik(fontSize: 25,color: Theme.of(context).indicatorColor,fontStyle: FontStyle.normal,fontWeight: FontWeight.w500),
),
Upvotes: 0
Views: 511
Reputation: 520
You extracted widget generateItem()
outside the state class, _picturesState
.
So you have to pass the context
of that state class as an argument of the generateItem()
. Then you are allowed to use that context inside of Theme.of(context)
.
Your final solution is:
Card generateItem(BuildContext context) {
return Card(
//..
);
}
And when you call this widget, simply pass context as an argument like:
return Container(
child: Column(
children:[
generateItem(context);
]
)
);
This should be inside of your state class which has its own context.
Upvotes: 1