2

定型コードを使用して、次のような 1 つのストアからデータを取得します。

MonthStore monthStore = new MonthStore();
monthStore.open().then((months) {

しかし、関連する複数のストアからデータを取得するのに苦労しています。これは私ができる最善のことですか?

MonthStore monthStore = new MonthStore();
monthStore.open().then((months) {
  TranStore tranStore = new TranStore();
  tranStore.open().then((trans) {

    // months[trans.monthId].name

  });
});

こんな感じで使ってFuture.waitみました

// declare the stores
MonthStore monthStore = new MonthStore();
TranStore tranStore = new TranStore();

Future.wait(
  [
    getMonth(monthStore, intMonth),
    // another call
  ]
)
.then...

Future<Map> getMonth(mnthStore, mnth) {
  mnthStore.open()
    .then((mnths) {
      return mnths[mnth];
    })
  // need a return here!
});

しかし、編集者は、将来に指定されたリターンはないと言っています。

ここで何が欠けていますか?

4

1 に答える 1