Add a util for displaying toasts
This commit is contained in:
parent
c75551db99
commit
8f0b606713
|
@ -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<SetupPage> {
|
|||
_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);
|
||||
});
|
||||
|
|
|
@ -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<ShareFolderWidget> {
|
|||
_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();
|
||||
},
|
||||
),
|
||||
|
|
13
lib/utils/toast_util.dart
Normal file
13
lib/utils/toast_util.dart
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue