簡體   English   中英

錯誤:未為類“ dart.core :: int”定義方法“ []”

[英]Error: The method '[]' isn't defined for the class 'dart.core::int'

運行flutter項目時出現錯誤,我需要幫助。 我做了一個克隆

https://github.com/miketraverso/devfestapp

更新所有軟件包后-我收到以下錯誤:編譯器消息:

lib/views/scheduled_session_widget.dart:51:34: Error: The method '[]' isn't defined for the class 'dart.core::int'.
Try correcting the name to the name of an existing method, or defining a method named '[]'.
mSessions[sessionIter['0'].toString()]; // ignore: undefined_operator

有人可以解釋我該怎么做才能解決此錯誤?

會話似乎是整數的集合: List<int> sessions; 在TimeSlot類中,稍后您可以使用forEach,因此可以將該代碼替換為:

 timeSlot.sessions.forEach((sessionIter) {
      Session session = mSessions[sessionIter.toString()];
      if (session != null) {
        Widget sessionCard = buildSessionCard(timeSlot, session);
        sessionCards.add(sessionCard);
      }
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM