Skip to content

Commit 7fbd388

Browse files
Merge pull request #41 from shruti-techindustan/dio_update
Dio Update Libraries
2 parents 4bfdeaa + 8d74326 commit 7fbd388

14 files changed

+591
-171
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@
2525
## 2.0.5
2626

2727
* Support Null Safety and code improvement
28+
29+
## 2.0.6
30+
31+
* Support custom list item builder, error handled and minor fixes
32+
33+
## 2.0.7
34+
35+
* Update dio dependency and minor improvements

README.md

+29-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ dependencies:
1212

1313
# Google AutoComplete TextField Widget code
1414

15-
1615
```
1716
GooglePlaceAutoCompleteTextField(
1817
textEditingController: controller,
@@ -29,12 +28,40 @@ dependencies:
2928
controller.text=prediction.description;
3029
controller.selection = TextSelection.fromPosition(TextPosition(offset: prediction.description.length));
3130
}
31+
// if we want to make custom list item builder
32+
itemBuilder: (context, index, Prediction prediction) {
33+
return Container(
34+
padding: EdgeInsets.all(10),
35+
child: Row(
36+
children: [
37+
Icon(Icons.location_on),
38+
SizedBox(
39+
width: 7,
40+
),
41+
Expanded(child: Text("${prediction.description??""}"))
42+
],
43+
),
44+
);
45+
}
46+
// if you want to add seperator between list items
47+
seperatedBuilder: Divider(),
48+
// want to show close icon
49+
isCrossBtnShown: true,
50+
// optional container padding
51+
containerHorizontalPadding: 10,
52+
53+
54+
55+
3256
)
3357
3458
```
59+
3560
# Customization Option
36-
You can customize a text field input decoration and debounce time
61+
62+
You can customize a text field input decoration and debounce time
3763

3864
# Screenshorts
65+
3966
<img src="sample.jpg" height="400">
4067

example/android/app/build.gradle

+12-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 28
29+
compileSdkVersion 33
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'
@@ -40,7 +40,7 @@ android {
4040
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4141
applicationId "com.example.example"
4242
minSdkVersion 16
43-
targetSdkVersion 28
43+
targetSdkVersion 33
4444
versionCode flutterVersionCode.toInteger()
4545
versionName flutterVersionName
4646
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -53,6 +53,16 @@ android {
5353
signingConfig signingConfigs.debug
5454
}
5555
}
56+
57+
compileOptions {
58+
sourceCompatibility JavaVersion.VERSION_1_8
59+
targetCompatibility JavaVersion.VERSION_1_8
60+
}
61+
kotlinOptions {
62+
jvmTarget = 1.8
63+
}
64+
65+
namespace 'com.example.example'
5666
}
5767

5868
flutter {

example/android/app/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<uses-permission android:name="android.permission.INTERNET" />
99

1010
<application
11-
android:name="io.flutter.app.FlutterApplication"
11+
android:name="${applicationName}"
1212
android:label="example"
1313
android:icon="@mipmap/ic_launcher">
1414
<activity
@@ -17,6 +17,7 @@
1717
android:theme="@style/LaunchTheme"
1818
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1919
android:hardwareAccelerated="true"
20+
android:exported="true"
2021
android:windowSoftInputMode="adjustResize">
2122
<intent-filter>
2223
<action android:name="android.intent.action.MAIN"/>

example/android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.50'
2+
ext.kotlin_version = '1.8.21'
33
repositories {
44
google()
55
jcenter()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath 'com.android.tools.build:gradle:8.0.1'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}
@@ -26,6 +26,6 @@ subprojects {
2626
project.evaluationDependsOn(':app')
2727
}
2828

29-
task clean(type: Delete) {
29+
tasks.register("clean", Delete) {
3030
delete rootProject.buildDir
3131
}

example/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-8.0-bin.zip

example/lib/main.dart

+44-19
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class MyApp extends StatelessWidget {
1919
}
2020

2121
class MyHomePage extends StatefulWidget {
22-
MyHomePage({Key key, this.title}) : super(key: key);
22+
MyHomePage({Key? key, this.title}) : super(key: key);
2323

24-
final String title;
24+
final String? title;
2525

2626
@override
2727
_MyHomePageState createState() => _MyHomePageState();
@@ -36,7 +36,7 @@ class _MyHomePageState extends State<MyHomePage> {
3636
appBar: AppBar(
3737
// Here we take the value from the MyHomePage object that was created by
3838
// the App.build method, and use it to set our appbar title.
39-
title: Text(widget.title),
39+
title: Text(widget.title ?? ""),
4040
),
4141
body: Center(
4242
// Center is a layout widget. It takes a single child and positions it
@@ -70,23 +70,48 @@ class _MyHomePageState extends State<MyHomePage> {
7070
return Container(
7171
padding: EdgeInsets.symmetric(horizontal: 20),
7272
child: GooglePlaceAutoCompleteTextField(
73-
textEditingController: controller,
74-
googleAPIKey: "YOUR_GOOGLE_API_KEY",
75-
inputDecoration: InputDecoration(hintText: "Search your location"),
76-
debounceTime: 800,
77-
countries: ["in", "fr"],
78-
isLatLngRequired: true,
79-
getPlaceDetailWithLatLng: (Prediction prediction) {
80-
print("placeDetails" + prediction.lng.toString());
81-
},
82-
itmClick: (Prediction prediction) {
83-
controller.text = prediction.description;
73+
textEditingController: controller,
74+
googleAPIKey:"YOUR_GOOGLE_API_KEY",
75+
inputDecoration: InputDecoration(
76+
hintText: "Search your location",
77+
border: InputBorder.none,
78+
enabledBorder: InputBorder.none,
79+
),
80+
debounceTime: 400,
81+
countries: ["in", "fr"],
82+
isLatLngRequired: false,
83+
getPlaceDetailWithLatLng: (Prediction prediction) {
84+
print("placeDetails" + prediction.lat.toString());
85+
},
86+
87+
itemClick: (Prediction prediction) {
88+
controller.text = prediction.description ?? "";
89+
controller.selection = TextSelection.fromPosition(
90+
TextPosition(offset: prediction.description?.length ?? 0));
91+
},
92+
seperatedBuilder: Divider(),
93+
containerHorizontalPadding: 10,
94+
95+
// OPTIONAL// If you want to customize list view item builder
96+
itemBuilder: (context, index, Prediction prediction) {
97+
return Container(
98+
padding: EdgeInsets.all(10),
99+
child: Row(
100+
children: [
101+
Icon(Icons.location_on),
102+
SizedBox(
103+
width: 7,
104+
),
105+
Expanded(child: Text("${prediction.description??""}"))
106+
],
107+
),
108+
);
109+
},
84110

85-
controller.selection = TextSelection.fromPosition(
86-
TextPosition(offset: prediction.description.length));
87-
}
88-
// default 600 ms ,
89-
),
111+
isCrossBtnShown: true,
112+
113+
// default 600 ms ,
114+
),
90115
);
91116
}
92117
}

0 commit comments

Comments
 (0)