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

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

上级 f868e529
...@@ -40,7 +40,7 @@ android { ...@@ -40,7 +40,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // 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. // 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. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21 minSdkVersion 21
......
...@@ -37,5 +37,26 @@ end ...@@ -37,5 +37,26 @@ end
post_install do |installer| post_install do |installer|
installer.pods_project.targets.each do |target| installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(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
end end
...@@ -76,7 +76,6 @@ ...@@ -76,7 +76,6 @@
1524F5A1B9D3662D6A78231F /* Pods-Runner.release.xcconfig */, 1524F5A1B9D3662D6A78231F /* Pods-Runner.release.xcconfig */,
D0C713F81EBEDF94521829B7 /* Pods-Runner.profile.xcconfig */, D0C713F81EBEDF94521829B7 /* Pods-Runner.profile.xcconfig */,
); );
name = Pods;
path = Pods; path = Pods;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
...@@ -205,6 +204,7 @@ ...@@ -205,6 +204,7 @@
files = ( files = (
); );
inputPaths = ( inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
); );
name = "Thin Binary"; name = "Thin Binary";
outputPaths = ( outputPaths = (
...@@ -365,7 +365,7 @@ ...@@ -365,7 +365,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterClxBaseExample; PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterBase;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
...@@ -494,7 +494,7 @@ ...@@ -494,7 +494,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterClxBaseExample; PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterBase;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
...@@ -517,7 +517,7 @@ ...@@ -517,7 +517,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterClxBaseExample; PRODUCT_BUNDLE_IDENTIFIER = com.clx.flutterBase;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
...@@ -24,6 +26,8 @@ ...@@ -24,6 +26,8 @@
<string>$(FLUTTER_BUILD_NUMBER)</string> <string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
...@@ -43,9 +47,5 @@ ...@@ -43,9 +47,5 @@
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<false/> <false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict> </dict>
</plist> </plist>
...@@ -24,6 +24,7 @@ class MyApp extends StatelessWidget { ...@@ -24,6 +24,7 @@ class MyApp extends StatelessWidget {
supportedLocales: AppTranslations.supportedLocales, supportedLocales: AppTranslations.supportedLocales,
locale: Get.deviceLocale, locale: Get.deviceLocale,
fallbackLocale: AppTranslations.fallbackLocale, fallbackLocale: AppTranslations.fallbackLocale,
builder: EasyLoading.init(),
localizationsDelegates: const [ localizationsDelegates: const [
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_clx_base/flutter_clx_base.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/widget/normal_dialog.dart';
import 'package:flutter_clx_base_example/sample/base_list_widget_test.dart'; import 'package:flutter_clx_base_example/sample/base_list_widget_test.dart';
import 'package:flutter_clx_base_example/sample/dio_widget_test.dart'; import 'package:flutter_clx_base_example/sample/dio_widget_test.dart';
...@@ -30,9 +31,23 @@ class Sample extends StatelessWidget { ...@@ -30,9 +31,23 @@ class Sample extends StatelessWidget {
fullWidthButton: true, fullWidthButton: true,
onPressed: () { onPressed: () {
// 1、manifest配置权限 // 1、manifest配置权限
requestPermission(permissionList: [Permission.camera],toSettingTip: "请开启相机权限"); requestPermission(
permissionList: [Permission.camera], toSettingTip: "请开启相机权限");
}, },
text: '动态申请权限'), 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. ...@@ -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 # The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages. # 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 publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 2.0.0+2
environment: environment:
sdk: '>=2.17.0 <3.0.0' 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: ...@@ -56,7 +56,10 @@ dependencies:
flutter_spinkit: ^5.1.0 flutter_spinkit: ^5.1.0
# https://pub.dev/packages/pretty_dio_logger # https://pub.dev/packages/pretty_dio_logger
pretty_dio_logger: ^1.3.1 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论