Skip to content

Instantly share code, notes, and snippets.

View DK15's full-sized avatar

Darshan Kawar DK15

View GitHub Profile
@DK15
DK15 / textfield-ontap.dart
Created June 9, 2020 12:52
TextField onTap behavior with different routes
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@DK15
DK15 / multi-level-dropdown.dart
Created June 9, 2020 12:13
Multi-level dropdownbuttonformfield example
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@DK15
DK15 / image_picker.dart
Created June 9, 2020 11:19
Build failure using image_picker
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@DK15
DK15 / status_bar_color.dart
Created June 9, 2020 10:45
Status bar color change
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white,
));
runApp(MyApp());
}
@DK15
DK15 / format_utc_date.dart
Last active April 8, 2020 09:28
Converting timestamp in specific format in Dart
/*
Many a times we receive timestamp from an api which is in this format -> 2020-04-08T12:20:40.000Z. We ofcourse can't use
this date as is in the UI. Hence, we first need to convert it into a readable or specific format.
*/
// Notice the `T` in the given date. It acts as a separator between `date` and `time` and doesn't hold any significance. Hence we will separate the given date using `substring()` method as below:
var str = "2020-04-08T12:20:40.000Z";
var newStr = str.substring(0,10) + ' ' + str.substring(11,23);
print(newStr); // 2020-04-08 12:20:40.000
@DK15
DK15 / feature_file_creation
Created April 26, 2019 13:23
Steps to create Cucumber feature file in Android Studio
Right-click on features folder and select New -> Edit File Templates that will open File and Code Templates Dialog.
Click on `+' icon and write down “Cucumber feature file” in the name field and “feature” in the extensions field.
Press Apply and OK buttons to confirm the new item creation.
Right-click on features folder again select New and you will see Cucumber Feature file template. Select this option and name the file as login.
Observe that login.feature file is now created under features folder.
@DK15
DK15 / gist:b15f60127d705065d8b435c79a0964c1
Created November 27, 2018 17:49
search with autocomplete
class ProCategories extends StatefulWidget {
final FirebaseUser fireBaseuser;
ProCategories(this.fireBaseuser, this.categories);
final List<Categories> categories;
@override
_ProCategoriesState createState() => new _ProCategoriesState(fireBaseuser);
[{
"Rating": 4,
"Review": "He connected with me immediately on a Saturday and quickly diagnosed and helped me fix my burst water pipe. He's very prompt, professional, and nice. I highly recommend. 4 stars.",
"Created": "2016-11-22 21:13:23",
"FullName": "Michael Carey",
"City": "Spring Lake",
"State": "WI",
"profile_pic": "https:\/\/randomuser.me\/api\/portraits\/men\/64.jpg"
}, {
"Rating": 3,
Widget _getReviewTile(Review review) {
// Keep only the day, month, and year
var date = review.created.split(" ")[0];
return new Container(
child: new Row(
children: <Widget>[
new Column(
children: <Widget>[
new Text('${review.fullName}',
style: TextStyle(color: Colors.black)),
@DK15
DK15 / reviews
Created October 19, 2018 09:41
PODO
class Review {
final int rating;
final String review;
final String created;
final String fullName;
final String city;
final String state;
final String profilePicURL;