Skip to content

Instantly share code, notes, and snippets.

View amalChandran's full-sized avatar
🎯
Focusing

Amal Chandran amalChandran

🎯
Focusing
View GitHub Profile
@amalChandran
amalChandran / main.dart
Last active September 9, 2024 08:28
A card view which supports ridges on one of its any four sides. When combined with another card, this will look like a tearable ticket!
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@amalChandran
amalChandran / main.dart
Created September 6, 2024 01:29
A gist to visually explain canvas based rotation of a path. This has rotation animation along with path unravel animation.
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@amalChandran
amalChandran / main.dart
Created September 5, 2024 12:02
A simple rect rotated with an animation
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@amalChandran
amalChandran / main.dart
Last active August 31, 2024 19:34
a simple dent animation using two bezier curves
import 'package:flutter/material.dart';
void main() {
runApp(DentAnimationWidget());
}
class DentAnimationWidget extends StatefulWidget {
@override
_DentAnimationWidgetState createState() => _DentAnimationWidgetState();
}
@amalChandran
amalChandran / gist:34ab9f1adf80bb83476a0cc5710e4138
Created July 24, 2024 05:28
Solid Flutter - Open-Closed Principle Example
import 'package:flutter/material.dart';
// Bad Example: Violating Open-Closed Principle
class BadButton extends StatelessWidget {
final String type;
final String label;
final VoidCallback onPressed;
BadButton({
required this.type,
@amalChandran
amalChandran / gist:e01fae6901c0ef39adb04f0197d25db3
Created July 24, 2024 05:16
Solid Flutter - Single Responsibility Principle Example
import 'package:flutter/material.dart';
// Bad Example: A widget that does too much
class BadSocialMediaPostWidget extends StatelessWidget {
final String username;
final String postContent;
final String imageUrl;
final int likes;
final List<String> comments;
When Edison had been an unknown inventor who specialized in the
telegraphic equipment business, reporters had not sought him out and begged
him for an opportunity to become his friend. Now, however, in early May 1878,
sycophantic journalists led him to believe that he was wise in all manner of
subjects, far afield of the electrical business. If they wished to listen to his
opinions, and they did indeed, he was glad to hold forth on any topic, such as the
relationship of diet to national destiny, a lecture delivered over lunch while
digging into strawberry shortcake, strawberries and cream, and an apple
dumpling.
@amalChandran
amalChandran / Map.java
Created January 13, 2017 04:51
How to Set Polyline fit to screen
public void onMapReady(GoogleMap googleMap) {
map.clear();
map = googleMap;
LatLng hcmus = new LatLng(Double.parseDouble(latitude1), Double.parseDouble(longitude1));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(hcmus, 10));
originMarkers.add(map.addMarker(new MarkerOptions()
.title(mStudentObject.getAddress())
.position(hcmus)));
LatLng startMarker=new LatLng(Double.parseDouble(latitude1),Double.parseDouble(longitude1));
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
@amalChandran
amalChandran / BezInterpolator.java
Last active November 1, 2019 13:11
Easy custom interpolators for android.
public class BezInterpolator {
private static BezInterpolator bezInterpolator;
//Control points to create the cubic bezier curve.
private float[] PRINCIPLE_DEFAULT_EASE = {(float)0.25, (float)0.1, (float)0.25, (float)1.0};
private float[] EASE_OUT = {(float)0, (float)0, (float)0.58, (float)1.0};
private float[] EASE_IN = {(float)0.42, (float)0, (float)1.0, (float)1.0};
public static BezInterpolator getInstance(){