Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: secure_store compatible with flutter 3.27.1 #429

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/secure_store/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
namespace 'com.example.secure_store'

compileSdkVersion 31

compileOptions {
Expand All @@ -43,6 +45,10 @@ android {
defaultConfig {
minSdkVersion 23
}

buildFeatures {
buildConfig = true
}
}

dependencies {
Expand Down
19 changes: 6 additions & 13 deletions packages/secure_store/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,10 +22,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.example.example"
compileSdkVersion flutter.compileSdkVersion
Expand Down Expand Up @@ -66,7 +63,3 @@ android {
flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
13 changes: 0 additions & 13 deletions packages/secure_store/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
30 changes: 22 additions & 8 deletions packages/secure_store/example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}

include ":app"
41 changes: 24 additions & 17 deletions packages/wallet_kit/lib/wallet_screens/protect_wallet_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class ProtectWalletScreen extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final isLoading = useState(false);
final isBiometryAvailable = BiometricsStore.isSupportedPlatform()
? useFuture(BiometricsStore().isAvailable()).data
: false;
final isBiometricSupported =
useMemoized(() => BiometricsStore.isSupportedPlatform(), []);
return Layout2(
sideMargin: 32,
children: [
Expand All @@ -28,21 +27,29 @@ class ProtectWalletScreen extends HookConsumerWidget {
"This extra layer of security helps prevent someone with your phone from accesing your funds.",
),
const Spacer(),
if (isBiometryAvailable == true)
PrimaryButton(
label: "Protect with biometrics",
isLoading: isLoading.value,
onPressed: () async {
isLoading.value = true;
await ref.read(walletsProvider.notifier).addWallet(
secureStore: BiometricsStore(),
seedPhrase: seedPhrase,
if (isBiometricSupported)
FutureBuilder(
future: BiometricsStore().isAvailable(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return PrimaryButton(
label: "Protect with biometrics",
isLoading: isLoading.value,
onPressed: () async {
isLoading.value = true;
await ref.read(walletsProvider.notifier).addWallet(
secureStore: BiometricsStore(),
seedPhrase: seedPhrase,
);
isLoading.value = false;
// ignore: use_build_context_synchronously
Navigator.of(context).popUntil((route) => route.isFirst);
},
);
isLoading.value = false;
// ignore: use_build_context_synchronously
Navigator.of(context).popUntil((route) => route.isFirst);
},
),
} else {
return const SizedBox.shrink();
}
}),
ptisserand marked this conversation as resolved.
Show resolved Hide resolved
SecondaryButton(
isLoading: isLoading.value,
onPressed: () async {
Expand Down
Loading