提交 efafef4f authored 作者: shixiaochen's avatar shixiaochen

1、修改包名(com.clx.flutterBase);2、增加DeviceUtils(获取设备、应用信息工具);

上级 f868e529
......@@ -40,7 +40,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
applicationId "com.clx.flutterBase"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
......
......@@ -37,5 +37,26 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
# Start of the permission_handler configuration
target.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
# You can enable the permissions needed here. For example to enable camera
# permission, just remove the `#` character in front so it looks like this:
#
# ## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=1'
#
# Preprocessor definitions can be found in: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
]
# 适配Xcode14.3和iOS16
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
# End of the permission_handler configuration
end
end
......@@ -76,7 +76,6 @@
1524F5A1B9D3662D6A78231F /* Pods-Runner.release.xcconfig */,
D0C713F81EBEDF94521829B7 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
......@@ -205,6 +204,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
......@@ -365,7 +365,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterClxBaseExample;
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterBase;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
......@@ -494,7 +494,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterClxBaseExample;
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterBase;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
......@@ -517,7 +517,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterClxBaseExample;
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterBase;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
......
......@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
......@@ -24,6 +26,8 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
......@@ -43,9 +47,5 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
......@@ -24,6 +24,7 @@ class MyApp extends StatelessWidget {
supportedLocales: AppTranslations.supportedLocales,
locale: Get.deviceLocale,
fallbackLocale: AppTranslations.fallbackLocale,
builder: EasyLoading.init(),
localizationsDelegates: const [
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
......
import 'package:flutter/material.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:flutter_clx_base/utils/device_utils.dart';
import 'package:flutter_clx_base/widget/normal_dialog.dart';
import 'package:flutter_clx_base_example/sample/base_list_widget_test.dart';
import 'package:flutter_clx_base_example/sample/dio_widget_test.dart';
......@@ -30,9 +31,23 @@ class Sample extends StatelessWidget {
fullWidthButton: true,
onPressed: () {
// 1、manifest配置权限
requestPermission(permissionList: [Permission.camera],toSettingTip: "请开启相机权限");
requestPermission(
permissionList: [Permission.camera], toSettingTip: "请开启相机权限");
},
text: '动态申请权限'),
GFButton(
fullWidthButton: true,
onPressed: () async {
var deviceModel = await DeviceUtils.getDeviceModel();
var versionName = await DeviceUtils.getVersionName();
var versionCode = await DeviceUtils.getVersionCode();
var deviceSerial = await DeviceUtils.getDeviceSerial();
debugPrint("===== deviceModel = $deviceModel "
" versionName = $versionName "
" versionCode = $versionCode "
" deviceSerial = $deviceSerial");
},
text: '获取设备信息'),
],
);
}
......
......@@ -3,6 +3,7 @@ description: Demonstrates how to use the flutter_clx_base plugin.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 2.0.0+2
environment:
sdk: '>=2.17.0 <3.0.0'
......
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/services.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:unique_identifier/unique_identifier.dart';
class DeviceUtils {
//uuid
static getDeviceSerial() async {
if (Platform.isAndroid) {
String? identifier = "Unknown";
try {
identifier = await UniqueIdentifier.serial ?? "Unknown";
} on PlatformException {
identifier = "Unknown";
}
return identifier;
} else if (Platform.isIOS) {
String? identifier = "Unknown";
try {
// TODO: 2023/7/6 iOS获取序列号
// identifier = await VersionUtils.getUuidForKeychain();
} on PlatformException {
identifier = "Unknown";
}
return identifier;
}
}
static getVersionName() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
}
static getVersionCode() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.buildNumber.toInt();
}
static getDeviceModel() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
return androidInfo.model;
} else {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
return iosInfo.name;
}
}
}
......@@ -56,7 +56,10 @@ dependencies:
flutter_spinkit: ^5.1.0
# https://pub.dev/packages/pretty_dio_logger
pretty_dio_logger: ^1.3.1
# 获取设备唯一标识 https://pub.dev/packages/unique_identifier
unique_identifier: ^0.3.0
# 设备信息 https://pub.dev/packages/device_info_plus
device_info_plus: ^8.1.0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论