Use a different toast library on iOS

This commit is contained in:
Vishnu Mohandas 2021-06-28 23:55:35 +05:30
parent 7f0deae679
commit 0b71e19962
4 changed files with 41 additions and 8 deletions

View file

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:background_fetch/background_fetch.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:in_app_purchase/in_app_purchase.dart';
import 'package:path_provider/path_provider.dart';
import 'package:photos/core/constants.dart';
@ -227,6 +228,7 @@ class EnteApp extends StatelessWidget with WidgetsBindingObserver {
theme: themeData,
home: _homeWidget,
debugShowCheckedModeBanner: false,
builder: EasyLoading.init(),
);
}

View file

@ -1,13 +1,29 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:fluttertoast/fluttertoast.dart';
Future<void> showToast(String message, {toastLength: Toast.LENGTH_LONG}) {
return Fluttertoast.showToast(
msg: message,
toastLength: toastLength,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.blueGrey[900],
textColor: Colors.white,
fontSize: 16.0);
if (Platform.isAndroid) {
return Fluttertoast.showToast(
msg: message,
toastLength: toastLength,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.blueGrey[900],
textColor: Colors.white,
fontSize: 16.0);
} else {
EasyLoading.instance
..backgroundColor = Colors.blueGrey[900]
..indicatorColor = Colors.blueGrey[900]
..textColor = Colors.white
..loadingStyle = EasyLoadingStyle.custom;
return EasyLoading.showToast(
message,
duration: Duration(seconds: (toastLength == Toast.LENGTH_LONG ? 4 : 3)),
toastPosition: EasyLoadingToastPosition.bottom,
);
}
}

View file

@ -260,6 +260,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
flutter_easyloading:
dependency: "direct main"
description:
name: flutter_easyloading
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
flutter_email_sender:
dependency: "direct main"
description:
@ -344,6 +351,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
flutter_spinkit:
dependency: transitive
description:
name: flutter_spinkit
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
flutter_test:
dependency: "direct dev"
description: flutter

View file

@ -91,6 +91,7 @@ dependencies:
pinput: ^1.2.0
intl: ^0.17.0
confetti: ^0.5.5
flutter_easyloading: ^3.0.0
dev_dependencies:
flutter_test: