Skip to content

Commit

Permalink
Dart 3 (#103)
Browse files Browse the repository at this point in the history
* dart 3.0.0

* dart 3.0.0

* pub

* pub

* pub

* pub

* pub

* up

* up
  • Loading branch information
hoc081098 authored Oct 27, 2024
1 parent 5f423c6 commit f79d173
Show file tree
Hide file tree
Showing 44 changed files with 569 additions and 488 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:

strategy:
matrix:
flutter-channel: [ 'stable', 'beta' ]
flutter-channel: [ 'stable' ]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'

- uses: subosito/flutter-action@v2
with:
Expand All @@ -33,7 +33,7 @@ jobs:
run: flutter --version

- name: Install dependencies
run: flutter pub get
run: dart pub get

- name: Format code
if: ${{ matrix.flutter-channel == 'stable' }}
Expand All @@ -44,7 +44,7 @@ jobs:
run: dart analyze lib

- name: Gen code
run: flutter packages pub run build_runner build --delete-conflicting-outputs
run: dart run build_runner build --delete-conflicting-outputs

- name: Build Debug APK
run: flutter build apk --debug --no-shrink
Expand Down
6 changes: 6 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-raw-types: true
strict-inference: true

linter:
rules:
- prefer_final_locals
Expand Down
32 changes: 18 additions & 14 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

kotlin {
jvmToolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.AZUL
}
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +19,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,12 +29,9 @@ 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 {
compileSdkVersion 33
compileSdkVersion 34
namespace "com.hoc.node_auth"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -45,7 +50,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.hoc.node_auth"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
Expand All @@ -65,11 +70,10 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.multidex:multidex:2.0.1"

implementation "com.google.crypto.tink:tink-android:1.7.0"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0-RC.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0-RC.2'
}
3 changes: 1 addition & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hoc.node_auth">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
19 changes: 3 additions & 16 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

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

allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}

Expand All @@ -26,6 +13,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
32 changes: 24 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
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.5.2" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

rootProject.name = "github_search"
include ":app"
4 changes: 2 additions & 2 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:node_auth/pages/reset_password/reset_password_page.dart';
import 'package:node_auth/utils/streams.dart';

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -81,7 +81,7 @@ class MyApp extends StatelessWidget {
}

class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
const Home({super.key});

@override
State<Home> createState() => _HomeState();
Expand Down
8 changes: 6 additions & 2 deletions lib/data/local/entities/user_and_token_entity.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions lib/data/local/entities/user_entity.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions lib/data/local/shared_pref_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ class SharedPrefUtil implements LocalDataSource {
// Encoder and Decoder
//

FutureOr<UserAndTokenEntity?> _toEntity(dynamic jsonString) =>
jsonString == null
? null
: _crypto
.decrypt(jsonString as String)
.then((s) => UserAndTokenEntity.fromJson(jsonDecode(s)));
FutureOr<UserAndTokenEntity?> _toEntity(dynamic jsonString) => jsonString ==
null
? null
: _crypto.decrypt(jsonString as String).then((s) =>
UserAndTokenEntity.fromJson(jsonDecode(s) as Map<String, dynamic>));

FutureOr<String?> _toString(UserAndTokenEntity? entity) =>
entity == null ? null : _crypto.encrypt(jsonEncode(entity));
Expand Down
12 changes: 6 additions & 6 deletions lib/data/remote/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ApiService implements RemoteDataSource {
HttpHeaders.authorizationHeader: basic,
},
cancelToken: cancelToken,
);
) as Map<String, dynamic>;
return TokenResponse.fromJson(json);
});

Expand All @@ -87,7 +87,7 @@ class ApiService implements RemoteDataSource {
url,
body: body,
cancelToken: cancelToken,
);
) as Map<String, dynamic>;
return TokenResponse.fromJson(decoded);
});

Expand All @@ -106,7 +106,7 @@ class ApiService implements RemoteDataSource {
url,
headers: {xAccessToken: token},
cancelToken: cancelToken,
);
) as Map<String, dynamic>;
return UserResponse.fromJson(json);
});

Expand All @@ -129,7 +129,7 @@ class ApiService implements RemoteDataSource {
headers: {xAccessToken: token},
body: body,
cancelToken: cancelToken,
);
) as Map<String, dynamic>;
return TokenResponse.fromJson(json);
});

Expand Down Expand Up @@ -160,7 +160,7 @@ class ApiService implements RemoteDataSource {
url,
cancelToken: cancelToken,
);
final json = await task;
final json = await task as Map<String, dynamic>;
return TokenResponse.fromJson(json);
});

Expand Down Expand Up @@ -198,7 +198,7 @@ class ApiService implements RemoteDataSource {
fields: {'user': email},
headers: {xAccessToken: token},
cancelToken: cancelToken,
);
) as Map<String, dynamic>;
return UserResponse.fromJson(decoded);
});
}
8 changes: 6 additions & 2 deletions lib/data/remote/response/token_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions lib/data/remote/response/user_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/data/serializers.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f79d173

Please sign in to comment.