Skip to content

Instantly share code, notes, and snippets.

View tailorvj's full-sized avatar
💭
Playing around with Next.js

Tailor VJ tailorvj

💭
Playing around with Next.js
View GitHub Profile
import 'package:flutter/material.dart';
final appHeight = 650.0;
final appWidth = 350.0;
final topSectionHeight = 250.0;
final middleSectionHeight = 110.0;
final List<String> urls = [ 'https://media.wired.com/photos/5d8aab8bef84070009028d31/master/pass/Plant-Music-1162975190.jpg',
'https://images.photowall.com/products/58131/jungle-plants.jpg?h=699&q=85',
'https://ak.picdn.net/shutterstock/videos/19795549/thumb/8.jpg',
'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSzIBq8nrrF631566zTKrioISfjIx9M868t-w&usqp=CAU',
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(home: MyWidget(), debugShowCheckedModeBanner: false),
);
}
class MyWidget extends StatelessWidget {
@override
@tailorvj
tailorvj / flutter-example-android-app-build.gradle
Created June 1, 2020 21:31
Flutter android/app/build.gradle with key.properties settings in it - change com.example.app_name to your app id
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
@tailorvj
tailorvj / try_catch_finally_exception.dart
Created April 17, 2020 14:26
try/catch/finally exception handling in Dart
void main() {
try {
print('going to throw an exception');
int.parse("some string");
}
catch (exception) {
print(exception);
}
finally{
print('this always runs');
@tailorvj
tailorvj / sort_list_of_objects.dart
Last active November 19, 2020 12:30
Example: sorting a list of objects in Dart
void main() {
List<FullName> fullNamesList = [FullName('Abe','Lincoln'), FullName('Babe', 'Ruth'), FullName('Carry', 'Bradshaw'),];
print ('fullNamesList:\n${fullNamesList.toString()}\n');
fullNamesList.sort((a,b) => a.lastName.compareTo(b.lastName));
print ('fullNamesList after sort by lastName:\n$fullNamesList\n');
fullNamesList.sort((a,b) => a.firstName.compareTo(b.firstName));
print ('fullNamesList after sort by firstName:\n$fullNamesList\n');
}
@tailorvj
tailorvj / simple_class_example.dart
Last active April 7, 2020 15:37
A simple Dart class example
void main(){
FullName myName = FullName('Tailor', 'VJ');
print(myName);
}
class FullName{
String firstName;
String lastName;
FullName(this.firstName, this.lastName);
String toString(){
@tailorvj
tailorvj / combine_maps_using_spread_operator.dart
Created April 7, 2020 08:53
Dart example: combining 2 Map objects with the spread operator
void main(){
Map map1 = {1: 'one', 2: 'two'};
Map map2 = {3: 'three', 4: 'four'};
Map map3 = {...map1, ...map2};
print('map1: $map1');
print('map2: $map2');
print('map3: $map3');
}
@tailorvj
tailorvj / iterating_through_a_Map.dart
Created April 7, 2020 08:05
Dart example: Iterating through a Map
void main(){
Map<String, int> scores = {'Bob': 300};
print('Initial state of the scores Map: $scores');
for (var key in ['Bob', 'Rohan', 'Sophena']) {
scores.putIfAbsent(key, () => key.length);
}
for (MapEntry entry in scores.entries){
print('scores[\'${entry.key}\']: ${entry.value}');
@tailorvj
tailorvj / flutter_basic_app_stateless_widget_main.dart
Created March 31, 2020 10:42
The most basic Flutter app in the world
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@tailorvj
tailorvj / dart_list_iterable_collection.dart
Last active April 7, 2020 06:40
Dart: Lists are Iterable Collections
main() {
var list = ['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon'];
for (var item in list){
print('${list.indexOf(item)}: $item');
}
}