Skip to content

Instantly share code, notes, and snippets.

View himanshusharma89's full-sized avatar
๐Ÿ’™
Developing

HIMANSHU SHARMA himanshusharma89

๐Ÿ’™
Developing
View GitHub Profile
@himanshusharma89
himanshusharma89 / normalization.dart
Created May 14, 2021 10:30
Normalize the JSON object
void main() {
String date = json['sheet']![0]['date']!;
String key = json['sheet']![0]['date']!;
List<Map<String, String>> outPut = [];
print(json['sheet']?.map((e){
for(int i=1;i<=4;i++){
outPut.add({
"date": date,
"uniqueKey": key,
"city$i":e["city$i"]!
@himanshusharma89
himanshusharma89 / findIncreasingPoint.dart
Last active May 14, 2021 10:28
find the Increasing Point in array
void main() {
List<int> array = [25, 23, 21, 16, 5, 10, 12, 16, 18];
int l =0 , r=array.length - 1;
while (l < r) {
int mid = l + (r-l)~/2;
if (array[mid] < array[mid + 1]) {
r = mid;
}
else {
l = mid + 1;
@himanshusharma89
himanshusharma89 / helloworld.dart
Created January 11, 2021 12:48
MLH Local Hack Day: Build Day 1 challenge "Hello, World in a New Language".
void main() {
print('Hello, World!');
}
Widget listItem({int index, String title, IconData icon}) {
final GlobalKey expansionTileKey = GlobalKey();
return Material(
color: Colors.transparent,
child: Theme(
data: ThemeData(accentColor: Colors.black),
child: ExpansionTile(
key: expansionTileKey,
onExpansionChanged: (value) {
if (value) {
void _scrollToSelectedContent({GlobalKey expansionTileKey}) {
final keyContext = expansionTileKey.currentContext;
if (keyContext != null) {
Future.delayed(Duration(milliseconds: 200)).then((value) {
Scrollable.ensureVisible(keyContext,
duration: Duration(milliseconds: 200));
});
}
}
Widget cardWidget() {
return Padding(
padding: const EdgeInsets.only(top: 5.0, bottom: 8),
child: Container(
width: MediaQuery.of(context).size.width * 0.91,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
Widget listItem({int index, String title, IconData icon}) {
return Material(
color: Colors.transparent,
child: Theme(
data: ThemeData(accentColor: Colors.black),
child: ExpansionTile(
leading: Icon(
icon,
size: 40,
),
ListView(
shrinkWrap: true,
primary: false,
children: [
listItem(title: "See more", icon: Icons.dashboard_rounded),
listItem(title: "Help & Support", icon: Icons.help_rounded),
listItem(title: "Setting & Privacy", icon: Icons.settings),
ListTile(
leading: Icon(
Icons.open_in_new_rounded,
@himanshusharma89
himanshusharma89 / ripple_effect_in_custom_buttons.dart
Last active November 7, 2020 14:56
Ripple Effect in Custom Buttons
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: MyWidget(),
),
);
}
Widget build(BuildContext context) {
return RepaintBoundary(
key: previewContainer,
child: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height * 0.05,