Skip to content

Commit

Permalink
Merge pull request #41 from shruti-techindustan/dio_update
Browse files Browse the repository at this point in the history
Dio Update Libraries
  • Loading branch information
Shrutimahajan authored Jan 9, 2024
2 parents 4bfdeaa + 8d74326 commit 7fbd388
Show file tree
Hide file tree
Showing 14 changed files with 591 additions and 171 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@
## 2.0.5

* Support Null Safety and code improvement

## 2.0.6

* Support custom list item builder, error handled and minor fixes

## 2.0.7

* Update dio dependency and minor improvements
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dependencies:

# Google AutoComplete TextField Widget code


```
GooglePlaceAutoCompleteTextField(
textEditingController: controller,
Expand All @@ -29,12 +28,40 @@ dependencies:
controller.text=prediction.description;
controller.selection = TextSelection.fromPosition(TextPosition(offset: prediction.description.length));
}
// if we want to make custom list item builder
itemBuilder: (context, index, Prediction prediction) {
return Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
Icon(Icons.location_on),
SizedBox(
width: 7,
),
Expanded(child: Text("${prediction.description??""}"))
],
),
);
}
// if you want to add seperator between list items
seperatedBuilder: Divider(),
// want to show close icon
isCrossBtnShown: true,
// optional container padding
containerHorizontalPadding: 10,
)
```

# Customization Option
You can customize a text field input decoration and debounce time

You can customize a text field input decoration and debounce time

# Screenshorts

<img src="sample.jpg" height="400">

14 changes: 12 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -40,7 +40,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -53,6 +53,16 @@ android {
signingConfig signingConfigs.debug
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = 1.8
}

namespace 'com.example.example'
}

flutter {
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="example"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -17,6 +17,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.8.21'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:8.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/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-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
63 changes: 44 additions & 19 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, this.title}) : super(key: key);

final String title;
final String? title;

@override
_MyHomePageState createState() => _MyHomePageState();
Expand All @@ -36,7 +36,7 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
title: Text(widget.title ?? ""),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
Expand Down Expand Up @@ -70,23 +70,48 @@ class _MyHomePageState extends State<MyHomePage> {
return Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: GooglePlaceAutoCompleteTextField(
textEditingController: controller,
googleAPIKey: "YOUR_GOOGLE_API_KEY",
inputDecoration: InputDecoration(hintText: "Search your location"),
debounceTime: 800,
countries: ["in", "fr"],
isLatLngRequired: true,
getPlaceDetailWithLatLng: (Prediction prediction) {
print("placeDetails" + prediction.lng.toString());
},
itmClick: (Prediction prediction) {
controller.text = prediction.description;
textEditingController: controller,
googleAPIKey:"YOUR_GOOGLE_API_KEY",
inputDecoration: InputDecoration(
hintText: "Search your location",
border: InputBorder.none,
enabledBorder: InputBorder.none,
),
debounceTime: 400,
countries: ["in", "fr"],
isLatLngRequired: false,
getPlaceDetailWithLatLng: (Prediction prediction) {
print("placeDetails" + prediction.lat.toString());
},

itemClick: (Prediction prediction) {
controller.text = prediction.description ?? "";
controller.selection = TextSelection.fromPosition(
TextPosition(offset: prediction.description?.length ?? 0));
},
seperatedBuilder: Divider(),
containerHorizontalPadding: 10,

// OPTIONAL// If you want to customize list view item builder
itemBuilder: (context, index, Prediction prediction) {
return Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
Icon(Icons.location_on),
SizedBox(
width: 7,
),
Expanded(child: Text("${prediction.description??""}"))
],
),
);
},

controller.selection = TextSelection.fromPosition(
TextPosition(offset: prediction.description.length));
}
// default 600 ms ,
),
isCrossBtnShown: true,

// default 600 ms ,
),
);
}
}
Loading

0 comments on commit 7fbd388

Please sign in to comment.