Skip to content

Instantly share code, notes, and snippets.

Avatar

Darshan Kawar DK15

View GitHub Profile
@DK15
DK15 / textfield-ontap.dart
Created Jun 9, 2020
TextField onTap behavior with different routes
View textfield-ontap.dart
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 Jun 9, 2020
Multi-level dropdownbuttonformfield example
View multi-level-dropdown.dart
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 Jun 9, 2020
Build failure using image_picker
View image_picker.dart
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 Jun 9, 2020
Status bar color change
View status_bar_color.dart
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 Apr 8, 2020
Converting timestamp in specific format in Dart
View format_utc_date.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 Apr 26, 2019
Steps to create Cucumber feature file in Android Studio
View feature_file_creation
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.
View gist:b15f60127d705065d8b435c79a0964c1
class ProCategories extends StatefulWidget {
final FirebaseUser fireBaseuser;
ProCategories(this.fireBaseuser, this.categories);
final List<Categories> categories;
@override
_ProCategoriesState createState() => new _ProCategoriesState(fireBaseuser);
View gist:5f1dcc6b7511688b31757d8e92c7b0a6
[{
"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,
View gist:783af00ade80f676ee670c61c7802cc9
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)),
View reviews
class Review {
final int rating;
final String review;
final String created;
final String fullName;
final String city;
final String state;
final String profilePicURL;