mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
fix: Add toast service to simplify creation of toasts
This commit is contained in:
23
lib/services/toast.dart
Normal file
23
lib/services/toast.dart
Normal file
@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart' as t;
|
||||
|
||||
class Toast {
|
||||
final t.FToast _fToast = t.FToast();
|
||||
late BuildContext buildContext;
|
||||
|
||||
void initialize(BuildContext context) {
|
||||
_fToast.init(context);
|
||||
}
|
||||
|
||||
void show(String text) {
|
||||
t.Fluttertoast.showToast(
|
||||
msg: FlutterI18n.translate(
|
||||
_fToast.context!,
|
||||
text,
|
||||
),
|
||||
toastLength: t.Toast.LENGTH_LONG,
|
||||
gravity: t.ToastGravity.CENTER,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user