getEditContent method

Widget getEditContent (
  1. BuildContext context
)

Implementation

Widget getEditContent(BuildContext context) {
  if (edit == true) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.end,
      children: <Widget>[
        IconButton(
          icon: Icon(
            Icons.report_problem,
            color: Colors.amber,
          ),
          onPressed: () async {
            String url = 'https://github.com/tianhaoz95/iwfp/issues/new';
            if (await canLaunch(url)) {
              await launch(url);
            } else {
              throw 'Could not launch $url';
            }
          },
        ),
        IconButton(
          icon: Icon(Icons.link),
          color: Colors.blue,
          key: Key(this.cardMetaData.id + '_link_btn'),
          onPressed: this.cardMetaData.hasOfficialUrl()
              ? () async {
                  String url = this.cardMetaData.officialUrl;
                  if (await canLaunch(url)) {
                    await launch(url);
                  } else {
                    throw 'Could not launch $url';
                  }
                }
              : null,
        ),
        IconButton(
            icon: Icon(Icons.edit),
            color: Colors.green,
            key: Key(this.cardMetaData.id + '_edit_btn'),
            onPressed: () {
              Navigator.pushNamed(context, '/edit_card',
                  arguments: cardMetaData);
            }),
        IconButton(
          icon: Icon(Icons.delete),
          color: Colors.redAccent,
          key: Key(this.cardMetaData.id + '_delete_btn'),
          onPressed: () {
            Navigator.pushNamed(context, '/remove_card',
                arguments: cardMetaData);
          },
        ),
      ],
    );
  } else {
    return null;
  }
}