💻 آخرین فرصت یادگیری برنامه‌نویسی با آفر ویژه قبل از افزایش قیمت در ۵ آذر ماه (🎁 به همراه یک هدیه ارزشمند )
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ شهاب صالحی
مشکل در setstate
جامعه فلاتر ایجاد شده در ۲۱ دی ۱۴۰۰

9b74-Screenshot (18).png

اینم کدی که نوشتم

class _MyHomePageState extends State<MyHomePage> {

  _SkillType _skill = _SkillType.photoShop;

  //_Language _language = _Language.en;


  void _updateSelectedSkill(_SkillType skillType) {

     setState(() {

ارور اینجاس

    this._skill = skillType;

    });

  }

اینم متن ارور

Exception has occurred.


FlutterError (setState() or markNeedsBuild() called during build.

This MyHomePage widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.

The widget on which setState() or markNeedsBuild() was called was:

MyHomePage

The widget which was currently being built when the offending call was made was:

Skill)

شهاب صالحی ۲۱ دی ۱۴۰۰، ۱۱:۳۷