Future can return null (#70324)

This commit is contained in:
Emmanuel Garcia 2020-11-12 10:29:04 -08:00 committed by GitHub
parent 0937207f5b
commit 0436886ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
typedef UpdateUrlFetcher = Future<String> Function();
typedef UpdateUrlFetcher = Future<String?> Function();
class Updater extends StatefulWidget {
const Updater({ required this.updateUrlFetcher, this.child, Key? key })
@ -35,9 +35,9 @@ class UpdaterState extends State<Updater> {
}
_lastUpdateCheck = DateTime.now();
final String updateUrl = await widget.updateUrlFetcher();
final String? updateUrl = await widget.updateUrlFetcher();
final bool? wantsUpdate = await showDialog<bool>(context: context, builder: _buildDialog);
if (wantsUpdate != null && wantsUpdate)
if (wantsUpdate != null && updateUrl != null && wantsUpdate)
launch(updateUrl);
}