Skip to content

Commit

Permalink
Future can return null (flutter#70324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia authored and angjieli committed Nov 13, 2020
1 parent d26712e commit abd03af
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -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 })
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit abd03af

Please sign in to comment.