Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Laxman Bhattarai erluxman

🏠
Working from home
View GitHub Profile
View digitafterdecimal.dart
void main() {
print(30.88922.withDecimalPoints(3)); //30.889
print(30.88922.withDecimalPointsFormatted(1)); //30.9
print(30.withDecimalPoints(3)); //30.0
print(30.withDecimalPointsFormatted(3)); //30.000
}
extension DecimalPoints on num {
double withDecimalPoints(int n) {
return num.parse(this.toStringAsFixed(n));
@erluxman
erluxman / main.yml
Last active Jun 12, 2020
Snippet for flutter build on github
View main.yml
on: push
name: Flutter CI
jobs:
build:
name: Build and Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
View installingflutter.sh
#If you are using zsh:
echo "\nexport PATH="\$PATH:`pwd`/flutter/bin"">>~/.zshrc ; source ~/.zshrc
#If you are using bash:
echo "\nexport PATH="\$PATH:`pwd`/flutter/bin"">>~/.bashrc ; source ~/.bashrc
@erluxman
erluxman / getnav.dart
Created May 30, 2020
Get navigation snippet
View getnav.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() => runApp(GetDemoApp());
class GetDemoApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
View dart_synchronous.dart
import 'dart:async';
import 'dart:io';
import 'package:synchronized/extension.dart';
main() async {
var demo = Demo();
await demo.runSynchronized();
await demo.runNotSynchronized();
}
View shadermask.dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
@erluxman
erluxman / color.dart
Created May 22, 2020
Colorfilters in dart
View color.dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
@erluxman
erluxman / dartrange.dart
Created May 19, 2020
Dart Range Extensions
View dartrange.dart
void main() {
// 2,3,4,5,6,7,8,9,10
for (int i in 2.to(10)) {
print(i);
}
// 2,3,4,5,6,7,8,9
for (int i in 2.until(10)) {
print(i);
}
@erluxman
erluxman / LoggingRetrofitRequestasJSON.kt
Created May 15, 2020
Logging JSON request in retrofit
View LoggingRetrofitRequestasJSON.kt
private val httpClient = OkHttpClient.Builder()
//This Interceptor is the main logging Interceptor
.addInterceptor { chain ->
val request = chain.request()
val jsonObj = JSONObject(Gson().toJson(request))
val requestBody = (jsonObj
?.getJSONObject("tags")
?.getJSONObject("class retrofit2.Invocation")
?.getJSONArray("arguments")?.get(0) ?: "").toString()
View animated_text_kit
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {