37 changed files with 1351 additions and 128 deletions
@ -1,5 +1,5 @@ |
|||||
class NWApi { |
class NWApi { |
||||
// static const baseApi = "https://www.deapsound.com"; |
// static const baseApi = "https://www.deapsound.com"; |
||||
static const baseApi = "https://api.ideapsound.com"; |
static const baseApi = "https://api.deapsound.com"; |
||||
// static const baseApi = "https://api.ideapsound.com"; |
// static const baseApi = "https://api.ideapsound.com"; |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,30 @@ |
|||||
|
import 'package:deep_voice/core/utils/logger.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
import 'package:user_portrait/user_portrait.dart'; |
||||
|
|
||||
|
//音乐播放管理 |
||||
|
class UserportraitManager extends GetxService { |
||||
|
static UserportraitManager get to => Get.find<UserportraitManager>(); |
||||
|
|
||||
|
// 音乐服务实例 |
||||
|
final UserPortrait _userPortrait = UserPortrait(); |
||||
|
|
||||
|
/// 初始化 |
||||
|
@override |
||||
|
void onInit() { |
||||
|
super.onInit(); |
||||
|
Logger.info('初始化权限请求'); |
||||
|
} |
||||
|
|
||||
|
/// 释放资源 |
||||
|
@override |
||||
|
void onClose() { |
||||
|
super.onClose(); |
||||
|
} |
||||
|
|
||||
|
//定位 |
||||
|
Future<void> clean() async { |
||||
|
_userPortrait.clean(); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
# Miscellaneous |
||||
|
*.class |
||||
|
*.log |
||||
|
*.pyc |
||||
|
*.swp |
||||
|
.DS_Store |
||||
|
.atom/ |
||||
|
.build/ |
||||
|
.buildlog/ |
||||
|
.history |
||||
|
.svn/ |
||||
|
.swiftpm/ |
||||
|
migrate_working_dir/ |
||||
|
|
||||
|
# IntelliJ related |
||||
|
*.iml |
||||
|
*.ipr |
||||
|
*.iws |
||||
|
.idea/ |
||||
|
|
||||
|
# The .vscode folder contains launch configuration and tasks you configure in |
||||
|
# VS Code which you may wish to be included in version control, so this line |
||||
|
# is commented out by default. |
||||
|
#.vscode/ |
||||
|
|
||||
|
# Flutter/Dart/Pub related |
||||
|
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. |
||||
|
/pubspec.lock |
||||
|
**/doc/api/ |
||||
|
.dart_tool/ |
||||
|
.flutter-plugins |
||||
|
.flutter-plugins-dependencies |
||||
|
build/ |
||||
@ -0,0 +1,33 @@ |
|||||
|
# This file tracks properties of this Flutter project. |
||||
|
# Used by Flutter tool to assess capabilities and perform upgrades etc. |
||||
|
# |
||||
|
# This file should be version controlled and should not be manually edited. |
||||
|
|
||||
|
version: |
||||
|
revision: "5c1433509f997e9059d230942bdf83f1b88a179e" |
||||
|
channel: "stable" |
||||
|
|
||||
|
project_type: plugin |
||||
|
|
||||
|
# Tracks metadata for the flutter migrate command |
||||
|
migration: |
||||
|
platforms: |
||||
|
- platform: root |
||||
|
create_revision: 5c1433509f997e9059d230942bdf83f1b88a179e |
||||
|
base_revision: 5c1433509f997e9059d230942bdf83f1b88a179e |
||||
|
- platform: android |
||||
|
create_revision: 5c1433509f997e9059d230942bdf83f1b88a179e |
||||
|
base_revision: 5c1433509f997e9059d230942bdf83f1b88a179e |
||||
|
- platform: ios |
||||
|
create_revision: 5c1433509f997e9059d230942bdf83f1b88a179e |
||||
|
base_revision: 5c1433509f997e9059d230942bdf83f1b88a179e |
||||
|
|
||||
|
# User provided section |
||||
|
|
||||
|
# List of Local paths (relative to this file) that should be |
||||
|
# ignored by the migrate tool. |
||||
|
# |
||||
|
# Files that are not part of the templates will be ignored by default. |
||||
|
unmanaged_files: |
||||
|
- 'lib/main.dart' |
||||
|
- 'ios/Runner.xcodeproj/project.pbxproj' |
||||
@ -0,0 +1,3 @@ |
|||||
|
## 0.0.1 |
||||
|
|
||||
|
* TODO: Describe initial release. |
||||
@ -0,0 +1 @@ |
|||||
|
TODO: Add your license here. |
||||
@ -0,0 +1,15 @@ |
|||||
|
# user_portrait |
||||
|
|
||||
|
用户画像 |
||||
|
|
||||
|
## Getting Started |
||||
|
|
||||
|
This project is a starting point for a Flutter |
||||
|
[plug-in package](https://flutter.dev/to/develop-plugins), |
||||
|
a specialized package that includes platform-specific implementation code for |
||||
|
Android and/or iOS. |
||||
|
|
||||
|
For help getting started with Flutter development, view the |
||||
|
[online documentation](https://docs.flutter.dev), which offers tutorials, |
||||
|
samples, guidance on mobile development, and a full API reference. |
||||
|
|
||||
@ -0,0 +1,4 @@ |
|||||
|
include: package:flutter_lints/flutter.yaml |
||||
|
|
||||
|
# Additional information about this file can be found at |
||||
|
# https://dart.dev/guides/language/analysis-options |
||||
@ -0,0 +1,9 @@ |
|||||
|
*.iml |
||||
|
.gradle |
||||
|
/local.properties |
||||
|
/.idea/workspace.xml |
||||
|
/.idea/libraries |
||||
|
.DS_Store |
||||
|
/build |
||||
|
/captures |
||||
|
.cxx |
||||
@ -0,0 +1,66 @@ |
|||||
|
group = "com.yunqiinnovation.user_portrait" |
||||
|
version = "1.0-SNAPSHOT" |
||||
|
|
||||
|
buildscript { |
||||
|
ext.kotlin_version = "2.1.0" |
||||
|
repositories { |
||||
|
google() |
||||
|
mavenCentral() |
||||
|
} |
||||
|
|
||||
|
dependencies { |
||||
|
classpath("com.android.tools.build:gradle:8.7.3") |
||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
allprojects { |
||||
|
repositories { |
||||
|
google() |
||||
|
mavenCentral() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
apply plugin: "com.android.library" |
||||
|
apply plugin: "kotlin-android" |
||||
|
|
||||
|
android { |
||||
|
namespace = "com.yunqiinnovation.user_portrait" |
||||
|
|
||||
|
compileSdk = 35 |
||||
|
|
||||
|
compileOptions { |
||||
|
sourceCompatibility = JavaVersion.VERSION_11 |
||||
|
targetCompatibility = JavaVersion.VERSION_11 |
||||
|
} |
||||
|
|
||||
|
kotlinOptions { |
||||
|
jvmTarget = JavaVersion.VERSION_11 |
||||
|
} |
||||
|
|
||||
|
sourceSets { |
||||
|
main.java.srcDirs += "src/main/kotlin" |
||||
|
test.java.srcDirs += "src/test/kotlin" |
||||
|
} |
||||
|
|
||||
|
defaultConfig { |
||||
|
minSdk = 21 |
||||
|
} |
||||
|
|
||||
|
dependencies { |
||||
|
testImplementation("org.jetbrains.kotlin:kotlin-test") |
||||
|
testImplementation("org.mockito:mockito-core:5.0.0") |
||||
|
} |
||||
|
|
||||
|
testOptions { |
||||
|
unitTests.all { |
||||
|
useJUnitPlatform() |
||||
|
|
||||
|
testLogging { |
||||
|
events "passed", "skipped", "failed", "standardOut", "standardError" |
||||
|
outputs.upToDateWhen {false} |
||||
|
showStandardStreams = true |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
rootProject.name = 'user_portrait' |
||||
@ -0,0 +1,3 @@ |
|||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
package="com.yunqiinnovation.user_portrait"> |
||||
|
</manifest> |
||||
@ -0,0 +1,90 @@ |
|||||
|
package com.yunqiinnovation.user_portrait |
||||
|
|
||||
|
import android.Manifest |
||||
|
import android.content.BroadcastReceiver |
||||
|
import android.content.Context |
||||
|
import android.content.Intent |
||||
|
import android.content.IntentFilter |
||||
|
import android.content.SharedPreferences |
||||
|
import android.location.LocationManager |
||||
|
import android.os.Build |
||||
|
import android.provider.Settings |
||||
|
import android.util.Log |
||||
|
import kotlinx.coroutines.SupervisorJob |
||||
|
import org.json.JSONObject |
||||
|
|
||||
|
/** UserPortraitPlugin */ |
||||
|
object UserPortrait { |
||||
|
private const val TAG = "UserPortrait" |
||||
|
private const val PREF_NAME = "deep_voice_user" |
||||
|
private var appcontext:Context? = null |
||||
|
private var prefs:SharedPreferences? = null |
||||
|
private var portrait: Map<String, Any?> = emptyMap() |
||||
|
|
||||
|
/** |
||||
|
* 初始化语音交互代理 |
||||
|
*/ |
||||
|
fun initialize(context: Context) { |
||||
|
try { |
||||
|
// 注册广播监听器 |
||||
|
val filter = IntentFilter().apply { |
||||
|
addAction("com.yunqiinnovation.user_portrait.UPDATE_PORTRAIT") |
||||
|
} |
||||
|
|
||||
|
// Android 14+ 需要指定 flag |
||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { |
||||
|
context.registerReceiver(controlReceiver, filter, Context.RECEIVER_NOT_EXPORTED) |
||||
|
} else { |
||||
|
context.registerReceiver(controlReceiver, filter) |
||||
|
} |
||||
|
// 获取SharedPreferences |
||||
|
appcontext = context; |
||||
|
prefs = appcontext?.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE) |
||||
|
portrait = prefs!!.all |
||||
|
|
||||
|
} catch (e: Exception) { |
||||
|
Log.e(TAG, "初始化语音交互代理时发生异常", e) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private val controlReceiver = object : BroadcastReceiver() { |
||||
|
override fun onReceive(context: Context?, intent: Intent?) { |
||||
|
Log.i(TAG, "接受到通知事件 ${intent?.action}") |
||||
|
when (intent?.action) { |
||||
|
"com.yunqiinnovation.user_portrait.UPDATE_PORTRAIT" -> { |
||||
|
|
||||
|
val key = intent.getStringExtra("key").toString() |
||||
|
val value = intent.getStringExtra("value").toString() |
||||
|
Log.i(TAG, "收到 UPDATE_PORTRAIT 广播 $key:$value") |
||||
|
if (key.isNotEmpty()) { |
||||
|
Log.i(TAG ,"接收到画像更新:$key = $value") |
||||
|
set(key, value) |
||||
|
} |
||||
|
} |
||||
|
// 你也可以扩展支持更多指令 |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
fun getAll(): Map<String, String> { |
||||
|
return portrait |
||||
|
.filterValues { it != null } // 可选,过滤掉 null |
||||
|
.mapValues { it.value.toString() } |
||||
|
} |
||||
|
|
||||
|
//设置画像字段 |
||||
|
fun set(key:String,value:String){ |
||||
|
val editor = prefs?.edit() |
||||
|
editor?.putString(key, value) |
||||
|
editor?.apply() // 异步提交(推荐) |
||||
|
portrait = portrait.toMutableMap().apply { |
||||
|
this[key] = value |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
fun clean(){ |
||||
|
portrait = emptyMap(); |
||||
|
prefs?.edit()?.clear()?.apply() |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,45 @@ |
|||||
|
package com.yunqiinnovation.user_portrait |
||||
|
|
||||
|
import android.content.BroadcastReceiver |
||||
|
import android.content.Context |
||||
|
import android.content.Intent |
||||
|
import android.content.IntentFilter |
||||
|
import android.os.Build |
||||
|
import android.util.Log |
||||
|
import androidx.core.content.ContextCompat.registerReceiver |
||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin |
||||
|
import io.flutter.plugin.common.MethodCall |
||||
|
import io.flutter.plugin.common.MethodChannel |
||||
|
import io.flutter.plugin.common.MethodChannel.MethodCallHandler |
||||
|
import io.flutter.plugin.common.MethodChannel.Result |
||||
|
|
||||
|
/** UserPortraitPlugin */ |
||||
|
class UserPortraitPlugin: FlutterPlugin, MethodCallHandler { |
||||
|
/// The MethodChannel that will the communication between Flutter and native Android |
||||
|
/// |
||||
|
/// This local reference serves to register the plugin with the Flutter Engine and unregister it |
||||
|
/// when the Flutter Engine is detached from the Activity |
||||
|
private lateinit var channel : MethodChannel |
||||
|
|
||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { |
||||
|
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "com.yunqiinnovation.user_portrait") |
||||
|
channel.setMethodCallHandler(this) |
||||
|
} |
||||
|
|
||||
|
override fun onMethodCall(call: MethodCall, result: Result) { |
||||
|
if (call.method == "clean") { |
||||
|
UserPortrait.clean() |
||||
|
result.success(null) |
||||
|
} else { |
||||
|
result.notImplemented() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { |
||||
|
channel.setMethodCallHandler(null) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
.idea/ |
||||
|
.vagrant/ |
||||
|
.sconsign.dblite |
||||
|
.svn/ |
||||
|
|
||||
|
.DS_Store |
||||
|
*.swp |
||||
|
profile |
||||
|
|
||||
|
DerivedData/ |
||||
|
build/ |
||||
|
GeneratedPluginRegistrant.h |
||||
|
GeneratedPluginRegistrant.m |
||||
|
|
||||
|
.generated/ |
||||
|
|
||||
|
*.pbxuser |
||||
|
*.mode1v3 |
||||
|
*.mode2v3 |
||||
|
*.perspectivev3 |
||||
|
|
||||
|
!default.pbxuser |
||||
|
!default.mode1v3 |
||||
|
!default.mode2v3 |
||||
|
!default.perspectivev3 |
||||
|
|
||||
|
xcuserdata |
||||
|
|
||||
|
*.moved-aside |
||||
|
|
||||
|
*.pyc |
||||
|
*sync/ |
||||
|
Icon? |
||||
|
.tags* |
||||
|
|
||||
|
/Flutter/Generated.xcconfig |
||||
|
/Flutter/ephemeral/ |
||||
|
/Flutter/flutter_export_environment.sh |
||||
@ -0,0 +1,29 @@ |
|||||
|
# |
||||
|
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. |
||||
|
# Run `pod lib lint user_portrait.podspec` to validate before publishing. |
||||
|
# |
||||
|
Pod::Spec.new do |s| |
||||
|
s.name = 'user_portrait' |
||||
|
s.version = '0.0.1' |
||||
|
s.summary = '用户画像' |
||||
|
s.description = <<-DESC |
||||
|
用户画像 |
||||
|
DESC |
||||
|
s.homepage = 'http://example.com' |
||||
|
s.license = { :file => '../LICENSE' } |
||||
|
s.author = { 'Your Company' => 'email@example.com' } |
||||
|
s.source = { :path => '.' } |
||||
|
s.source_files = 'user_portrait/Sources/user_portrait/**/*' |
||||
|
s.dependency 'Flutter' |
||||
|
s.platform = :ios, '12.0' |
||||
|
|
||||
|
# Flutter.framework does not contain a i386 slice. |
||||
|
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } |
||||
|
s.swift_version = '5.0' |
||||
|
|
||||
|
# If your plugin requires a privacy manifest, for example if it uses any |
||||
|
# required reason APIs, update the PrivacyInfo.xcprivacy file to describe your |
||||
|
# plugin's privacy impact, and then uncomment this line. For more information, |
||||
|
# see https://developer.apple.com/documentation/bundleresources/privacy_manifest_files |
||||
|
# s.resource_bundles = {'user_portrait_privacy' => ['user_portrait/Sources/user_portrait/PrivacyInfo.xcprivacy']} |
||||
|
end |
||||
@ -0,0 +1,32 @@ |
|||||
|
// swift-tools-version: 5.9 |
||||
|
// The swift-tools-version declares the minimum version of Swift required to build this package. |
||||
|
|
||||
|
import PackageDescription |
||||
|
|
||||
|
let package = Package( |
||||
|
name: "user_portrait", |
||||
|
platforms: [ |
||||
|
.iOS("12.0") |
||||
|
], |
||||
|
products: [ |
||||
|
.library(name: "user-portrait", targets: ["user_portrait"]) |
||||
|
], |
||||
|
dependencies: [], |
||||
|
targets: [ |
||||
|
.target( |
||||
|
name: "user_portrait", |
||||
|
dependencies: [], |
||||
|
resources: [ |
||||
|
// If your plugin requires a privacy manifest, for example if it uses any required |
||||
|
// reason APIs, update the PrivacyInfo.xcprivacy file to describe your plugin's |
||||
|
// privacy impact, and then uncomment these lines. For more information, see |
||||
|
// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files |
||||
|
// .process("PrivacyInfo.xcprivacy"), |
||||
|
|
||||
|
// If you have other resources that need to be bundled with your plugin, refer to |
||||
|
// the following instructions to add them: |
||||
|
// https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package |
||||
|
] |
||||
|
) |
||||
|
] |
||||
|
) |
||||
@ -0,0 +1,14 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-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>NSPrivacyTrackingDomains</key> |
||||
|
<array/> |
||||
|
<key>NSPrivacyAccessedAPITypes</key> |
||||
|
<array/> |
||||
|
<key>NSPrivacyCollectedDataTypes</key> |
||||
|
<array/> |
||||
|
<key>NSPrivacyTracking</key> |
||||
|
<false/> |
||||
|
</dict> |
||||
|
</plist> |
||||
@ -0,0 +1,19 @@ |
|||||
|
import Flutter |
||||
|
import UIKit |
||||
|
|
||||
|
public class UserPortraitPlugin: NSObject, FlutterPlugin { |
||||
|
public static func register(with registrar: FlutterPluginRegistrar) { |
||||
|
let channel = FlutterMethodChannel(name: "user_portrait", binaryMessenger: registrar.messenger()) |
||||
|
let instance = UserPortraitPlugin() |
||||
|
registrar.addMethodCallDelegate(instance, channel: channel) |
||||
|
} |
||||
|
|
||||
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { |
||||
|
switch call.method { |
||||
|
case "getPlatformVersion": |
||||
|
result("iOS " + UIDevice.current.systemVersion) |
||||
|
default: |
||||
|
result(FlutterMethodNotImplemented) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
import 'package:flutter/services.dart'; |
||||
|
|
||||
|
class UserPortrait { |
||||
|
static final UserPortrait _instance = UserPortrait._internal(); |
||||
|
|
||||
|
/// 获取单例 |
||||
|
factory UserPortrait() => _instance; |
||||
|
|
||||
|
// 方法通道 |
||||
|
final MethodChannel _methodChannel = MethodChannel( |
||||
|
'com.yunqiinnovation.user_portrait', |
||||
|
); |
||||
|
|
||||
|
// 内部构造函数 |
||||
|
UserPortrait._internal() {} |
||||
|
|
||||
|
/// 请求定位权限 |
||||
|
Future<void> clean() async { |
||||
|
try { |
||||
|
await _methodChannel.invokeMethod<void>('clean'); |
||||
|
return; |
||||
|
} catch (e) { |
||||
|
throw Exception('请求权限失败: $e'); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
name: user_portrait |
||||
|
description: "用户画像" |
||||
|
version: 0.0.1 |
||||
|
homepage: |
||||
|
|
||||
|
environment: |
||||
|
sdk: ^3.8.1 |
||||
|
flutter: '>=3.3.0' |
||||
|
|
||||
|
dependencies: |
||||
|
flutter: |
||||
|
sdk: flutter |
||||
|
plugin_platform_interface: ^2.0.2 |
||||
|
|
||||
|
dev_dependencies: |
||||
|
flutter_test: |
||||
|
sdk: flutter |
||||
|
flutter_lints: ^5.0.0 |
||||
|
|
||||
|
# For information on the generic Dart part of this file, see the |
||||
|
# following page: https://dart.dev/tools/pub/pubspec |
||||
|
|
||||
|
# The following section is specific to Flutter packages. |
||||
|
flutter: |
||||
|
# This section identifies this Flutter project as a plugin project. |
||||
|
# The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) |
||||
|
# which should be registered in the plugin registry. This is required for |
||||
|
# using method channels. |
||||
|
# The Android 'package' specifies package in which the registered class is. |
||||
|
# This is required for using method channels on Android. |
||||
|
# The 'ffiPlugin' specifies that native code should be built and bundled. |
||||
|
# This is required for using `dart:ffi`. |
||||
|
# All these are used by the tooling to maintain consistency when |
||||
|
# adding or updating assets for this project. |
||||
|
plugin: |
||||
|
platforms: |
||||
|
android: |
||||
|
package: com.yunqiinnovation.user_portrait |
||||
|
pluginClass: UserPortraitPlugin |
||||
|
ios: |
||||
|
pluginClass: UserPortraitPlugin |
||||
|
|
||||
|
# To add assets to your plugin package, add an assets section, like this: |
||||
|
# assets: |
||||
|
# - images/a_dot_burr.jpeg |
||||
|
# - images/a_dot_ham.jpeg |
||||
|
# |
||||
|
# For details regarding assets in packages, see |
||||
|
# https://flutter.dev/to/asset-from-package |
||||
|
# |
||||
|
# An image asset can refer to one or more resolution-specific "variants", see |
||||
|
# https://flutter.dev/to/resolution-aware-images |
||||
|
|
||||
|
# To add custom fonts to your plugin package, add a fonts section here, |
||||
|
# in this "flutter" section. Each entry in this list should have a |
||||
|
# "family" key with the font family name, and a "fonts" key with a |
||||
|
# list giving the asset and other descriptors for the font. For |
||||
|
# example: |
||||
|
# fonts: |
||||
|
# - family: Schyler |
||||
|
# fonts: |
||||
|
# - asset: fonts/Schyler-Regular.ttf |
||||
|
# - asset: fonts/Schyler-Italic.ttf |
||||
|
# style: italic |
||||
|
# - family: Trajan Pro |
||||
|
# fonts: |
||||
|
# - asset: fonts/TrajanPro.ttf |
||||
|
# - asset: fonts/TrajanPro_Bold.ttf |
||||
|
# weight: 700 |
||||
|
# |
||||
|
# For details regarding fonts in packages, see |
||||
|
# https://flutter.dev/to/font-from-package |
||||
@ -0,0 +1,27 @@ |
|||||
|
import 'package:flutter/services.dart'; |
||||
|
import 'package:flutter_test/flutter_test.dart'; |
||||
|
import 'package:user_portrait/user_portrait_method_channel.dart'; |
||||
|
|
||||
|
void main() { |
||||
|
TestWidgetsFlutterBinding.ensureInitialized(); |
||||
|
|
||||
|
MethodChannelUserPortrait platform = MethodChannelUserPortrait(); |
||||
|
const MethodChannel channel = MethodChannel('user_portrait'); |
||||
|
|
||||
|
setUp(() { |
||||
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( |
||||
|
channel, |
||||
|
(MethodCall methodCall) async { |
||||
|
return '42'; |
||||
|
}, |
||||
|
); |
||||
|
}); |
||||
|
|
||||
|
tearDown(() { |
||||
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null); |
||||
|
}); |
||||
|
|
||||
|
test('getPlatformVersion', () async { |
||||
|
expect(await platform.getPlatformVersion(), '42'); |
||||
|
}); |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
import 'package:flutter_test/flutter_test.dart'; |
||||
|
import 'package:user_portrait/user_portrait.dart'; |
||||
|
import 'package:user_portrait/user_portrait_platform_interface.dart'; |
||||
|
import 'package:user_portrait/user_portrait_method_channel.dart'; |
||||
|
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; |
||||
|
|
||||
|
class MockUserPortraitPlatform |
||||
|
with MockPlatformInterfaceMixin |
||||
|
implements UserPortraitPlatform { |
||||
|
|
||||
|
@override |
||||
|
Future<String?> getPlatformVersion() => Future.value('42'); |
||||
|
} |
||||
|
|
||||
|
void main() { |
||||
|
final UserPortraitPlatform initialPlatform = UserPortraitPlatform.instance; |
||||
|
|
||||
|
test('$MethodChannelUserPortrait is the default instance', () { |
||||
|
expect(initialPlatform, isInstanceOf<MethodChannelUserPortrait>()); |
||||
|
}); |
||||
|
|
||||
|
test('getPlatformVersion', () async { |
||||
|
UserPortrait userPortraitPlugin = UserPortrait(); |
||||
|
MockUserPortraitPlatform fakePlatform = MockUserPortraitPlatform(); |
||||
|
UserPortraitPlatform.instance = fakePlatform; |
||||
|
|
||||
|
expect(await userPortraitPlugin.getPlatformVersion(), '42'); |
||||
|
}); |
||||
|
} |
||||
Loading…
Reference in new issue