Skip to content

Instantly share code, notes, and snippets.

View jorwan's full-sized avatar

Jorge Wander Santana Ureña jorwan

View GitHub Profile
@jorwan
jorwan / main.dart
Created October 5, 2024 16:27
dashed line example
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@jorwan
jorwan / main.dart
Last active October 3, 2024 18:42
flutter-bloc-call-event-just-once.dart
/*
* Goal:
* Call event only on first time by bloc state
* */
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() => runApp(const MyApp());
@jorwan
jorwan / main.dart
Last active December 31, 2023 15:31
sort list with nulls at the end in dart
void main() {
print("Current list");
var l = [1,5,2,null,0];
print(l);
print("Sorted List");
l.sort((a, b) {
int result;
if (a == null) {
result = 1;
@jorwan
jorwan / main.dart
Created December 31, 2023 15:27
Test - Calling multiple times keep same result
void main() {
print("Current list");
var l = [1,5,2,null,0];
print(l);
print("Sorted List");
for(int i=0;i<10;i++){
sortIt(l);
print(l);
};
@jorwan
jorwan / main.dart
Last active December 31, 2023 15:23
Sort list with nulls
void main() {
print("Current list");
var l = [1,5,2,null,0];
print(l);
print("sort it asc with nulls at the beginning");
sortIt(l, asc:true, nullAtEnding: false);
print(l);
print("sort it asc with nulls at the end");
@jorwan
jorwan / project_list_data.json
Created July 25, 2021 02:17
Project List Data - This data feeds project list page in https://jorwan.github.io/
{
"projects": [
{
"title": "CAT FACTS",
"subtitle": "VIEW RANDOM PICTURES AND FACTS ABOUT CATS",
"description": "Flutter Mobile App that make a request to third-party api to get a cat picture and a request to another third-party api to get a cat fact.",
"repositoryUrl": "https://github.com/jorwan/cat-facts",
"previewUrl": "https://res.cloudinary.com/dufbnf0ov/image/upload/v1624586236/jorwan.github.io/preview_cat_fact.gif"
},
{
/*
Jorge Wander Santana Urena
[email protected]
*/
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@jorwan
jorwan / chunk_list_sample.dart
Last active May 28, 2023 15:43
Extension to chunk list
void main() => print(List.generate(10, (i) => i).chunk(3));
extension ListChunkerExtension on List {
List chunk(int chunkLength) {
if ((chunkLength ?? 0) <= 0 || (this ?? []).length == 0)
return this;
var chunks = [];
for (var i = 0; i < this.length; i += chunkLength) {
chunks.add(this.sublist(
i, i + chunkLength > this.length ? this.length : i + chunkLength));
@jorwan
jorwan / time_picker_widget.dart
Last active December 24, 2020 16:20
DEMO for custom time picker using time_picker_widget
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
void main() {
@jorwan
jorwan / remove_nulls.dart
Last active November 8, 2020 23:54
Remove property with null values and null values from list
/*
* Goal: Remove property with null values and null values from list
* Author: Jorge Wander Santana Urena
* Source: https://gist.github.com/jorwan/52902870f633da8959a39353e96fac25
**/
final data =
{
"name": "Carolina Ratliff",
"company": null,