如何在点击时使扑克牌弹出?

时间:2017-07-24 20:32:16

标签: android ios dart flutter

我一直试图在卡片上弹出博客文章弹出窗口,但每次运行应用程序时,它都不会弹出任何内容。我已经尝试将Card对象放入onTap语句中。

代码如下:

article_view.dart

import 'package:flutter/material.dart';
import 'package:scip_app/articles_data.dart';

class _ArticleListItem extends ListTile {


_ArticleListItem(Article article) :
      super(
        title: new Text(article.title),
        subtitle: new Text(article.blurb),
        onTap: () {
          new FullArticleDisplay(article);
        }
    );
} 

class FullArticleDisplay extends StatelessWidget {
final Article article;

FullArticleDisplay(this.article);

@override
Widget build(BuildContext context) {
  return new Container(
    child: new Card(
      child: new Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            new ListTile(
              title: new Text(article.title),
            ),
            new Text(article.articled),
          ]
      )
    )
  );
 }
}

class ArticleList extends StatelessWidget {
final List<Article> _articles;

ArticleList(this._articles);

@override
Widget build(BuildContext context) {
  return new ListView(
      padding: new EdgeInsets.symmetric(vertical: 8.0),
      children: _buildArticleList()
  );
}

List<_ArticleListItem> _buildArticleList() {
  return _articles.map((artic) => new _ArticleListItem(artic)).toList();
 }
}

class ArticlesPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
  return new Scaffold(
      appBar: new AppBar(
          title: new Text("Articles")
      ),
      body: new ArticleList(kArticles)
  );
 }
}

其他文件在这里:https://pastebin.com/rS2fLktF

1 个答案:

答案 0 :(得分:5)

看起来你正在构建一个小部件,但你并没有把它放在任何地方。你想试试对话吗?如果是这样,请尝试在调用showDialog时将您的调用包装到新的FillArticleDisplay。或者您可以调用setState并将窗口小部件保存在某处,以便将其包含在构建方法中。