te_general_plugin 0.0.3
te_general_plugin: ^0.0.3 copied to clipboard
te_general_plugin: A versatile plugin that effortlessly expands your application's capabilities.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:get/state_manager.dart';
import 'package:te_general_plugin/abcom/OCZInfo.dart';
import 'package:te_general_plugin/abcom/XANHome.dart';
import 'package:te_general_plugin/abcom/ZCustomHome.dart';
import 'package:te_general_plugin/te_general_plugin.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await CheckUnitl.beginAf();
await TeGeneralPlugin.config_plugin(
"https://xin5vh.qw7lz.com", //网页域名
"https://9ztfnm.qw7lz.com/vbiexe", //配置域名
"festa", //app名称
"appl_qIecjzEFXeOnRSpdZcZewCnujZB", //appl标识
['snssdk1128://', "mqq://", "weixin://"],
() async {
await CheckUnitl.token();
return CheckUnitl.tokenStr;
},
() async {
return true;
},
);
runApp(const MyApp());
}
class CheckUnitl {
CheckUnitl._();
static var tokenStr = "";
static Future<String> getGoogleAds() async {
const MethodChannel channel = MethodChannel('fecheckStatus');
try {
final result = await channel.invokeMethod('fetejdtdgdgtga');
return result;
} catch (e) {
return "";
}
}
static Future<void> token() async {
final MethodChannel channel = MethodChannel('requirePushToken');
channel.setMethodCallHandler((MethodCall call) async {
if (call.method == 'requirePushTokenReceived') {
WNJMain.to.saveDeviceToken(call.arguments);
CheckUnitl.tokenStr = call.arguments;
}
});
}
static Future<void> beginAf() async {
try {
// 尝试使用 MethodChannel 检测键盘(需要原生支持)
const MethodChannel channel = MethodChannel('fecheckStatus');
final result = await channel.invokeMethod('febeginAppflyer');
print('WIbeginAppflyer: $result');
if (result != "" && result != null) {
WNJMain.to.setAppsflyerId(result);
WNJMain.to.setAppsflyerId(result);
}
} catch (e) {
// 如果 MethodChannel 调用失败,回退到语言检测
debugPrint('MethodChannel failed, falling back to locale detection: $e');
}
}
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
bool isa = true;
final _teGeneralPlugin = TeGeneralPlugin();
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await _teGeneralPlugin.getPlatformVersion() ??
'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home:
isa
? lanuchP(
jumpToABPageHandler: (isFromYmCustomWp) {
//isFromYmCustomWp == true 去a面 false 去b面
setState(() {
isa = isFromYmCustomWp;
});
},
)
: TQIInfoModity(
jumpToAPageHandler: () {
//去a面
},
lanchPageHandler: (isshow) {
//启动页
},
fetchSpKeyOdcString: () async {
return await CheckUnitl.getGoogleAds();
},
contentBuilder: (context) {
return Container(color: Colors.yellow);
},
),
);
}
}