Тип сгруппированный Явное создание шаблонов

return new Scaffold(
    appBar: new AppBar(
      title: new Text("Listviews"),
    ),
    body: Container(
      padding: EdgeInsets.all(16.0),
      child: new ListView.builder(
        itemCount: data == null ? 0 : data["data"].length,
        itemBuilder: (BuildContext context, int index) {
          return new GestureDetector(
            child: new Card(
              child: new Text(data["data"][index]["title"]),
            ),
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => StandardsControlPage()),
              );
            },
          );
        },
      ),
    ));

Я думаю, что это сработает.

2
задан tangy 20 January 2019 в 08:41
поделиться

1 ответ

Вы можете решить проблему, добавив слой:

template <typename T>
struct Foo{
  Foo(T elem);

  T elem_;

  T get(){
     return do_get<T>();
     }

  private:

  template <typename U = T>
  auto do_get() -> std::enable_if_t<std::is_same<U, int>::value, U>;

  template <typename U = T>
  auto do_get() -> std::enable_if_t<std::is_same<U, bool>::value, U>;
   };
//If definitions for the do_get functions are provided before these
//explicit template instantiation definitions, the compiler will certainly
//inline those definitions.
template class Foo<int>;
template class Foo<bool>;
0
ответ дан Oliv 20 January 2019 в 08:41
поделиться
Другие вопросы по тегам:

Похожие вопросы: