diff --git a/lib/ui/setup_page.dart b/lib/ui/setup_page.dart index 3cf0905b4..a0d3c8fbd 100644 --- a/lib/ui/setup_page.dart +++ b/lib/ui/setup_page.dart @@ -4,6 +4,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:photos/core/configuration.dart'; import 'package:photos/ui/sign_in_widget.dart'; import 'package:photos/utils/endpoint_finder.dart'; +import 'package:photos/utils/toast_util.dart'; class SetupPage extends StatefulWidget { SetupPage({key}) : super(key: key); @@ -22,14 +23,7 @@ class _SetupPageState extends State { _shouldSearchForEndpoint) { EndpointFinder.instance.findEndpoint().then((endpoint) { if (mounted && endpoint != null) { - Fluttertoast.showToast( - msg: "Server discovery successful!", - toastLength: Toast.LENGTH_SHORT, - gravity: ToastGravity.BOTTOM, - timeInSecForIosWeb: 1, - backgroundColor: Colors.grey[600], - textColor: Colors.white, - fontSize: 16.0); + showToast("Server discovery successful!"); setState(() { Configuration.instance.setEndpoint(endpoint); }); diff --git a/lib/ui/share_folder_widget.dart b/lib/ui/share_folder_widget.dart index 94ea4c7b6..a00b83961 100644 --- a/lib/ui/share_folder_widget.dart +++ b/lib/ui/share_folder_widget.dart @@ -4,6 +4,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:photos/folder_service.dart'; import 'package:photos/models/folder.dart'; import 'package:photos/ui/loading_widget.dart'; +import 'package:photos/utils/toast_util.dart'; class ShareFolderWidget extends StatefulWidget { final String title; @@ -65,14 +66,7 @@ class _ShareFolderWidgetState extends State { _folder.sharedWith.clear(); _folder.sharedWith.addAll(sharedWith); await FolderSharingService.instance.updateFolder(_folder); - Fluttertoast.showToast( - msg: "Sharing configuration updated successfully.", - toastLength: Toast.LENGTH_SHORT, - gravity: ToastGravity.BOTTOM, - timeInSecForIosWeb: 1, - backgroundColor: Colors.grey[600], - textColor: Colors.white, - fontSize: 16.0); + showToast("Sharing configuration updated successfully."); Navigator.of(context).pop(); }, ), diff --git a/lib/utils/toast_util.dart b/lib/utils/toast_util.dart new file mode 100644 index 000000000..aa3623e3f --- /dev/null +++ b/lib/utils/toast_util.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; + +void showToast(String message) { + Fluttertoast.showToast( + msg: message, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.grey[600], + textColor: Colors.white, + fontSize: 16.0); +}