Skip to content

Commit 698a1a0

Browse files
committed
🔧 Fix AndroidX incompatibility
1 parent e41a2aa commit 698a1a0

File tree

21 files changed

+189
-101
lines changed

21 files changed

+189
-101
lines changed

.github/workflows/dart.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
# Get flutter packages
1717
- run: flutter pub get
1818
# Build :D
19-
- run: flutter build aot
19+
- run: flutter build

android/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
key.properties

android/app/build.gradle

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ if (flutterVersionName == null) {
2222
}
2323

2424
apply plugin: 'com.android.application'
25+
apply plugin: 'kotlin-android'
2526
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2627

2728
android {
28-
compileSdkVersion 28
29+
compileSdkVersion 30
2930

30-
lintOptions {
31-
disable 'InvalidPackage'
31+
sourceSets {
32+
main.java.srcDirs += 'src/main/kotlin'
3233
}
3334

3435
defaultConfig {
3536
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3637
applicationId "com.thealphamerc.flutter_ecommerce_app"
3738
minSdkVersion 16
38-
targetSdkVersion 28
39+
targetSdkVersion 30
3940
versionCode flutterVersionCode.toInteger()
4041
versionName flutterVersionName
41-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4242
}
4343

4444
buildTypes {
@@ -55,7 +55,5 @@ flutter {
5555
}
5656

5757
dependencies {
58-
testImplementation 'junit:junit:4.12'
59-
androidTestImplementation 'androidx.test:runner:1.1.1'
60-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
58+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6159
}

android/app/src/main/AndroidManifest.xml

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.thealphamerc.flutter_ecommerce_app">
3-
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
4-
calls FlutterMain.startInitialization(this); in its onCreate method.
5-
In most cases you can leave this as-is, but you if you want to provide
6-
additional functionality it is fine to subclass or reimplement
7-
FlutterApplication and put your custom class here. -->
8-
<uses-permission android:name="android.permission.INTERNET"/>
9-
<application
10-
android:name="io.flutter.app.FlutterApplication"
11-
android:label="Ecommerce App"
3+
<application
4+
android:label="flutter_ecommerce_app"
125
android:icon="@mipmap/ic_launcher">
136
<activity
147
android:name=".MainActivity"
@@ -17,6 +10,23 @@
1710
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1811
android:hardwareAccelerated="true"
1912
android:windowSoftInputMode="adjustResize">
13+
<!-- Specifies an Android theme to apply to this Activity as soon as
14+
the Android process has started. This theme is visible to the user
15+
while the Flutter UI initializes. After that, this theme continues
16+
to determine the Window background behind the Flutter UI. -->
17+
<meta-data
18+
android:name="io.flutter.embedding.android.NormalTheme"
19+
android:resource="@style/NormalTheme"
20+
/>
21+
<!-- Displays an Android View that continues showing the launch screen
22+
Drawable until Flutter paints its first frame, then this splash
23+
screen fades out. A splash screen is useful to avoid any visual
24+
gap between the end of Android's launch screen and the painting of
25+
Flutter's first frame. -->
26+
<meta-data
27+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
28+
android:resource="@drawable/launch_background"
29+
/>
2030
<intent-filter>
2131
<action android:name="android.intent.action.MAIN"/>
2232
<category android:name="android.intent.category.LAUNCHER"/>

android/app/src/main/java/com/thealphamerc/flutter_ecommerce_app/MainActivity.java

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.thealphamerc.flutter_ecommerce_app
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
5+
class MainActivity: FlutterActivity() {
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Modify this file to customize your launch splash screen -->
3+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item android:drawable="?android:colorBackground" />
5+
6+
<!-- You can insert your own image assets here -->
7+
<!-- <item>
8+
<bitmap
9+
android:gravity="center"
10+
android:src="@mipmap/launch_image" />
11+
</item> -->
12+
<item>
13+
<bitmap
14+
android:gravity="center"
15+
android:src="@drawable/ic_launcher" />
16+
</item>
17+
</layer-list>

android/app/src/main/res/drawable/launch_background.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
android:gravity="center"
1010
android:src="@mipmap/launch_image" />
1111
</item> -->
12-
<item>
12+
<item>
1313
<bitmap
1414
android:gravity="center"
1515
android:src="@drawable/ic_launcher" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
5+
<!-- Show a splash screen on the activity. Automatically removed when
6+
Flutter draws its first frame -->
7+
<item name="android:windowBackground">@drawable/launch_background</item>
8+
</style>
9+
<!-- Theme applied to the Android Window as soon as the process has started.
10+
This theme determines the color of the Android Window while your
11+
Flutter UI initializes, as well as behind your Flutter UI while its
12+
running.
13+
14+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
15+
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
16+
<item name="android:windowBackground">?android:colorBackground</item>
17+
</style>
18+
</resources>
+11-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
3+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
45
<!-- Show a splash screen on the activity. Automatically removed when
56
Flutter draws its first frame -->
67
<item name="android:windowBackground">@drawable/launch_background</item>
78
</style>
9+
<!-- Theme applied to the Android Window as soon as the process has started.
10+
This theme determines the color of the Android Window while your
11+
Flutter UI initializes, as well as behind your Flutter UI while its
12+
running.
13+
14+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
15+
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
16+
<item name="android:windowBackground">?android:colorBackground</item>
17+
</style>
818
</resources>

android/build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
buildscript {
2+
ext.kotlin_version = '1.3.50'
23
repositories {
34
google()
45
jcenter()
56
}
67

78
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath 'com.android.tools.build:gradle:4.1.0'
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
911
}
1012
}
1113

android/gradle.properties

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
2-
android.enableR8=true
32
android.useAndroidX=true
43
android.enableJetifier=true

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-5.6.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

android/settings.gradle

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
include ':app'
22

3-
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
3+
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4+
def properties = new Properties()
45

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9-
}
6+
assert localPropertiesFile.exists()
7+
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
108

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
15-
}
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"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>PreviewsEnabled</key>
6+
<false/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>PreviewsEnabled</key>
6+
<false/>
7+
</dict>
8+
</plist>

lib/src/model/data.dart

+17-12
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import 'package:flutter_ecommerce_app/src/model/product.dart';
44
class AppData {
55
static List<Product> productList = [
66
Product(
7-
id:1,
7+
id: 1,
88
name: 'Nike Air Max 200',
99
price: 240.00,
1010
isSelected: true,
1111
isliked: false,
1212
image: 'assets/shooe_tilt_1.png',
1313
category: "Trending Now"),
1414
Product(
15-
id:2,
15+
id: 2,
1616
name: 'Nike Air Max 97',
1717
price: 220.00,
1818
isliked: false,
@@ -21,29 +21,29 @@ class AppData {
2121
];
2222
static List<Product> cartList = [
2323
Product(
24-
id:1,
24+
id: 1,
2525
name: 'Nike Air Max 200',
2626
price: 240.00,
2727
isSelected: true,
2828
isliked: false,
2929
image: 'assets/small_tilt_shoe_1.png',
3030
category: "Trending Now"),
3131
Product(
32-
id:2,
32+
id: 2,
3333
name: 'Nike Air Max 97',
3434
price: 190.00,
3535
isliked: false,
3636
image: 'assets/small_tilt_shoe_2.png',
3737
category: "Trending Now"),
3838
Product(
39-
id:1,
39+
id: 1,
4040
name: 'Nike Air Max 92607',
4141
price: 220.00,
4242
isliked: false,
4343
image: 'assets/small_tilt_shoe_3.png',
4444
category: "Trending Now"),
45-
Product(
46-
id:2,
45+
Product(
46+
id: 2,
4747
name: 'Nike Air Max 200',
4848
price: 240.00,
4949
isSelected: true,
@@ -60,16 +60,21 @@ class AppData {
6060
];
6161
static List<Category> categoryList = [
6262
Category(),
63-
Category(id:1,name: "Sneakers",image: 'assets/shoe_thumb_2.png',isSelected: true),
64-
Category(id:2,name: "Jacket", image: 'assets/jacket.png'),
65-
Category(id:3,name: "Watch", image: 'assets/watch.png'),
66-
Category(id:4,name: "Watch", image: 'assets/watch.png'),
63+
Category(
64+
id: 1,
65+
name: "Sneakers",
66+
image: 'assets/shoe_thumb_2.png',
67+
isSelected: true),
68+
Category(id: 2, name: "Jacket", image: 'assets/jacket.png'),
69+
Category(id: 3, name: "Watch", image: 'assets/watch.png'),
70+
Category(id: 4, name: "Watch", image: 'assets/watch.png'),
6771
];
6872
static List<String> showThumbnailList = [
6973
"assets/shoe_thumb_5.png",
7074
"assets/shoe_thumb_1.png",
7175
"assets/shoe_thumb_4.png",
7276
"assets/shoe_thumb_3.png",
7377
];
74-
static String description = "Clean lines, versatile and timeless—the people shoe returns with the Nike Air Max 90. Featuring the same iconic Waffle sole, stitched overlays and classic TPU accents you come to love, it lets you walk among the pantheon of Air. ßNothing as fly, nothing as comfortable, nothing as proven. The Nike Air Max 90 stays true to its OG running roots with the iconic Waffle sole, stitched overlays and classic TPU details. Classic colours celebrate your fresh look while Max Air cushioning adds comfort to the journey.";
78+
static String description =
79+
"Clean lines, versatile and timeless—the people shoe returns with the Nike Air Max 90. Featuring the same iconic Waffle sole, stitched overlays and classic TPU accents you come to love, it lets you walk among the pantheon of Air. ßNothing as fly, nothing as comfortable, nothing as proven. The Nike Air Max 90 stays true to its OG running roots with the iconic Waffle sole, stitched overlays and classic TPU details. Classic colours celebrate your fresh look while Max Air cushioning adds comfort to the journey.";
7580
}

lib/src/widgets/extentions.dart

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
import 'package:flutter/material.dart';
22

33
extension OnPressed on Widget {
4-
Widget ripple(Function onPressed, {BorderRadiusGeometry borderRadius =const BorderRadius.all(Radius.circular(5))}) => Stack(
5-
children: <Widget>[
6-
this,
7-
Positioned(
8-
left: 0,
9-
right: 0,
10-
top: 0,
11-
bottom: 0,
12-
child: FlatButton(
13-
shape: RoundedRectangleBorder(
14-
borderRadius: borderRadius
15-
),
16-
onPressed: () {
17-
if (onPressed != null) {
18-
onPressed();
19-
}
20-
},
21-
child: Container()),
22-
)
23-
],
24-
);
25-
}
4+
Widget ripple(Function onPressed,
5+
{BorderRadiusGeometry borderRadius =
6+
const BorderRadius.all(Radius.circular(5))}) =>
7+
Stack(
8+
children: <Widget>[
9+
this,
10+
Positioned(
11+
left: 0,
12+
right: 0,
13+
top: 0,
14+
bottom: 0,
15+
child: TextButton(
16+
style: ButtonStyle(
17+
shape: MaterialStateProperty.all(
18+
RoundedRectangleBorder(borderRadius: borderRadius),
19+
)),
20+
onPressed: () {
21+
if (onPressed != null) {
22+
onPressed();
23+
}
24+
},
25+
child: Container()),
26+
)
27+
],
28+
);
29+
}

0 commit comments

Comments
 (0)