如何描述飞镖缺乏价值?

时间:2020-05-01 10:59:26

标签: dart

在回转运算符语句const filename = 'form.pdf'; const thisData = this; this.printElement = document.getElementById('content'); html2canvas(this.printElement).then(canvas => { this.pdfData = new jsPDF ('p', 'mm', 'a4'); this.imageHeight = canvas.height * 208 / canvas.width; this.pdfData.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0, 208, this.imageHeight); this.pdfData.save(filename); this.uploadFile(this.pdfData.output('blob')); }); } uploadFile(pdfFile: Blob) { this.uploadService.uploadFile(pdfFile) .subscribe( (data: any) => { if (data.responseCode === 200 ) { //succesfully uploaded to back end server }}, (error) => { //error occured } ) } 中,如果初始表达式的计算结果为假,我希望该语句不返回任何内容(您可以看到它正在返回打印语句),该怎么做?

下面给出了实际代码,返回类型不能为null。所以,这不是一个选择

5 == 5 ? print('Correct') : print('Wrong')

1 个答案:

答案 0 :(得分:1)

如果您的项目支持Dart 2.3.0或更高版本,则可以这样做:

Column(
   mainAxisAlignment: MainAxisAlignment.spaceAround,
   children: <Widget>[
     Text(times[index]),
     if (newMessagehasCome)
       Icon(Icons.laptop)
   ], 
)