feat: add fluttertoast localization with HarmonyOS support and ToastService
This commit is contained in:
1
packages/fluttertoast
Submodule
1
packages/fluttertoast
Submodule
Submodule packages/fluttertoast added at 60bfbda748
7
packages/fluttertoast_ohos/lib/fluttertoast_ohos.dart
Normal file
7
packages/fluttertoast_ohos/lib/fluttertoast_ohos.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'fluttertoast_platform_interface.dart';
|
||||
|
||||
class FluttertoastOhos extends FluttertoastPlatform {
|
||||
static void registerWith() {
|
||||
FluttertoastPlatform.instance = FluttertoastOhos();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
abstract class FluttertoastPlatform {
|
||||
static FluttertoastPlatform? instance;
|
||||
|
||||
static const MethodChannel _channel =
|
||||
MethodChannel('PonnamKarthik/fluttertoast');
|
||||
|
||||
Future<bool?> showToast({
|
||||
required String msg,
|
||||
String? toastLength,
|
||||
int timeInSecForIosWeb = 1,
|
||||
double? fontSize,
|
||||
String? fontAsset,
|
||||
String? gravity,
|
||||
int? backgroundColor,
|
||||
int? textColor,
|
||||
bool webShowClose = false,
|
||||
String webBgColor = "linear-gradient(to right, #00b09b, #96c93d)",
|
||||
String webPosition = "right",
|
||||
}) async {
|
||||
final Map<String, dynamic> params = <String, dynamic>{
|
||||
'msg': msg,
|
||||
'length': toastLength,
|
||||
'time': timeInSecForIosWeb,
|
||||
'gravity': gravity,
|
||||
'bgcolor': backgroundColor,
|
||||
'iosBgcolor': backgroundColor,
|
||||
'textcolor': textColor,
|
||||
'iosTextcolor': textColor,
|
||||
'fontSize': fontSize,
|
||||
'fontAsset': fontAsset,
|
||||
'webShowClose': webShowClose,
|
||||
'webBgColor': webBgColor,
|
||||
'webPosition': webPosition
|
||||
};
|
||||
|
||||
bool? res = await _channel.invokeMethod('showToast', params);
|
||||
return res;
|
||||
}
|
||||
|
||||
Future<bool?> cancel() async {
|
||||
bool? res = await _channel.invokeMethod("cancel");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
28
packages/fluttertoast_ohos/pubspec.yaml
Normal file
28
packages/fluttertoast_ohos/pubspec.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
name: fluttertoast_ohos
|
||||
description: Ohos implementation of the fluttertoast plugin.
|
||||
repository: https://github.com/PonnamKarthik/FlutterToast
|
||||
issue_tracker: https://github.com/ponnamkarthik/FlutterToast/issues
|
||||
version: 9.0.0
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <4.0.0"
|
||||
flutter: ">=1.10.0"
|
||||
|
||||
flutter:
|
||||
plugin:
|
||||
implements: fluttertoast
|
||||
platforms:
|
||||
ohos:
|
||||
package: io.github.ponnamkarthik.toast.fluttertoast
|
||||
pluginClass: FlutterToastPlugin
|
||||
dartPluginClass: FluttertoastOhos
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
fluttertoast:
|
||||
path: ../fluttertoast
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
Reference in New Issue
Block a user