Skip to content

Commit f79d173

Browse files
authored
Dart 3 (#103)
* dart 3.0.0 * dart 3.0.0 * pub * pub * pub * pub * pub * up * up
1 parent 5f423c6 commit f79d173

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+569
-488
lines changed

.github/workflows/flutter.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
flutter-channel: [ 'stable', 'beta' ]
15+
flutter-channel: [ 'stable' ]
1616

1717
steps:
1818
- uses: actions/checkout@v3
1919

2020
- uses: actions/setup-java@v3
2121
with:
2222
distribution: 'zulu'
23-
java-version: '11'
23+
java-version: '17'
2424

2525
- uses: subosito/flutter-action@v2
2626
with:
@@ -33,7 +33,7 @@ jobs:
3333
run: flutter --version
3434

3535
- name: Install dependencies
36-
run: flutter pub get
36+
run: dart pub get
3737

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

4646
- name: Gen code
47-
run: flutter packages pub run build_runner build --delete-conflicting-outputs
47+
run: dart run build_runner build --delete-conflicting-outputs
4848

4949
- name: Build Debug APK
5050
run: flutter build apk --debug --no-shrink

analysis_options.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
include: package:flutter_lints/flutter.yaml
22

3+
analyzer:
4+
language:
5+
strict-casts: true
6+
strict-raw-types: true
7+
strict-inference: true
8+
39
linter:
410
rules:
511
- prefer_final_locals

android/app/build.gradle

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
7+
kotlin {
8+
jvmToolchain {
9+
languageVersion = JavaLanguageVersion.of(17)
10+
vendor = JvmVendorSpec.AZUL
11+
}
12+
}
13+
114
def localProperties = new Properties()
215
def localPropertiesFile = rootProject.file('local.properties')
316
if (localPropertiesFile.exists()) {
@@ -6,11 +19,6 @@ if (localPropertiesFile.exists()) {
619
}
720
}
821

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
1422
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1523
if (flutterVersionCode == null) {
1624
flutterVersionCode = '1'
@@ -21,12 +29,9 @@ if (flutterVersionName == null) {
2129
flutterVersionName = '1.0'
2230
}
2331

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
2832
android {
29-
compileSdkVersion 33
33+
compileSdkVersion 34
34+
namespace "com.hoc.node_auth"
3035

3136
compileOptions {
3237
sourceCompatibility JavaVersion.VERSION_1_8
@@ -45,7 +50,7 @@ android {
4550
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4651
applicationId "com.hoc.node_auth"
4752
minSdkVersion 21
48-
targetSdkVersion 33
53+
targetSdkVersion 34
4954
versionCode flutterVersionCode.toInteger()
5055
versionName flutterVersionName
5156
multiDexEnabled true
@@ -65,11 +70,10 @@ flutter {
6570
}
6671

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

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

73-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
74-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
77+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0-RC.2'
78+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0-RC.2'
7579
}

android/app/src/main/AndroidManifest.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.hoc.node_auth">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32

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

android/build.gradle

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
buildscript {
2-
ext.kotlin_version = '1.6.10'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.1.0'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()
17-
mavenCentral()
4+
jcenter()
185
}
196
}
207

@@ -26,6 +13,6 @@ subprojects {
2613
project.evaluationDependsOn(':app')
2714
}
2815

29-
task clean(type: Delete) {
16+
tasks.register("clean", Delete) {
3017
delete rootProject.buildDir
31-
}
18+
}

android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip

android/settings.gradle

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.5.2" apply false
22+
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
23+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
24+
}
25+
26+
rootProject.name = "github_search"
27+
include ":app"

lib/app.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import 'package:node_auth/pages/reset_password/reset_password_page.dart';
1818
import 'package:node_auth/utils/streams.dart';
1919

2020
class MyApp extends StatelessWidget {
21-
const MyApp({Key? key}) : super(key: key);
21+
const MyApp({super.key});
2222

2323
@override
2424
Widget build(BuildContext context) {
@@ -81,7 +81,7 @@ class MyApp extends StatelessWidget {
8181
}
8282

8383
class Home extends StatefulWidget {
84-
const Home({Key? key}) : super(key: key);
84+
const Home({super.key});
8585

8686
@override
8787
State<Home> createState() => _HomeState();

lib/data/local/entities/user_and_token_entity.g.dart

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/local/entities/user_entity.g.dart

+8-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/local/shared_pref_util.dart

+5-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ class SharedPrefUtil implements LocalDataSource {
4848
// Encoder and Decoder
4949
//
5050

51-
FutureOr<UserAndTokenEntity?> _toEntity(dynamic jsonString) =>
52-
jsonString == null
53-
? null
54-
: _crypto
55-
.decrypt(jsonString as String)
56-
.then((s) => UserAndTokenEntity.fromJson(jsonDecode(s)));
51+
FutureOr<UserAndTokenEntity?> _toEntity(dynamic jsonString) => jsonString ==
52+
null
53+
? null
54+
: _crypto.decrypt(jsonString as String).then((s) =>
55+
UserAndTokenEntity.fromJson(jsonDecode(s) as Map<String, dynamic>));
5756

5857
FutureOr<String?> _toString(UserAndTokenEntity? entity) =>
5958
entity == null ? null : _crypto.encrypt(jsonEncode(entity));

lib/data/remote/api_service.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ApiService implements RemoteDataSource {
6262
HttpHeaders.authorizationHeader: basic,
6363
},
6464
cancelToken: cancelToken,
65-
);
65+
) as Map<String, dynamic>;
6666
return TokenResponse.fromJson(json);
6767
});
6868

@@ -87,7 +87,7 @@ class ApiService implements RemoteDataSource {
8787
url,
8888
body: body,
8989
cancelToken: cancelToken,
90-
);
90+
) as Map<String, dynamic>;
9191
return TokenResponse.fromJson(decoded);
9292
});
9393

@@ -106,7 +106,7 @@ class ApiService implements RemoteDataSource {
106106
url,
107107
headers: {xAccessToken: token},
108108
cancelToken: cancelToken,
109-
);
109+
) as Map<String, dynamic>;
110110
return UserResponse.fromJson(json);
111111
});
112112

@@ -129,7 +129,7 @@ class ApiService implements RemoteDataSource {
129129
headers: {xAccessToken: token},
130130
body: body,
131131
cancelToken: cancelToken,
132-
);
132+
) as Map<String, dynamic>;
133133
return TokenResponse.fromJson(json);
134134
});
135135

@@ -160,7 +160,7 @@ class ApiService implements RemoteDataSource {
160160
url,
161161
cancelToken: cancelToken,
162162
);
163-
final json = await task;
163+
final json = await task as Map<String, dynamic>;
164164
return TokenResponse.fromJson(json);
165165
});
166166

@@ -198,7 +198,7 @@ class ApiService implements RemoteDataSource {
198198
fields: {'user': email},
199199
headers: {xAccessToken: token},
200200
cancelToken: cancelToken,
201-
);
201+
) as Map<String, dynamic>;
202202
return UserResponse.fromJson(decoded);
203203
});
204204
}

lib/data/remote/response/token_response.g.dart

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/remote/response/user_response.g.dart

+8-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/serializers.g.dart

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)