Skip to content

Instantly share code, notes, and snippets.

@dbmessina
dbmessina / main.dart
Created December 19, 2023 19:57
List filtering
class DummyModel {
const DummyModel({required this.title, required this.categories});
final String title;
final List<String> categories;
}
const kDummies = [
DummyModel(
title: "first",
categories: ["a", "b", "c", "d", "e"],
@dbmessina
dbmessina / main.dart
Last active November 20, 2023 21:10
MK8D randomizer logic
void main() {
var numRaces = 8;
var tracksSelected = [1, 2, 3];
var finalTrackList = [];
// Add tracksSelected.length tracks at a time to finalTrackList
do {
print("outer loop");
@dbmessina
dbmessina / main.dart
Created July 17, 2023 16:44
Variable scope
int globalVar = 400;
void main() {
int abc = 123;
print("abc in main() - $abc");
print("globalVar in main() - $globalVar\n");
updateMyVars(abc: abc);
@dbmessina
dbmessina / main.dart
Last active July 2, 2023 18:36
Reference material
void main() {
List<String> letters = ["a", "b", "c"];
// The next two variables are random whatever,
// but used to show we can manipulate them inside of our loops
// We can do more than print()!
// Just happen to use print() a lot to learn, visualize, and debug
// That's about all you use it for actually, app user will never see your print()s
List<String> allLetters = [];
int growingNumber = 2;
@dbmessina
dbmessina / main.dart
Last active July 13, 2023 17:29
Fibonacci Sequence
/*
Fibonacci sequence - 0, 1, 1, 2, 3, 5, 8, 13...
Write a function that takes in the number of the Fibonacci sequence
that I want to find and it will return that number.
For example, if I pass in 8, the function will return 13. I'll print
the number in main().
I already know that the first two numbers in the sequence are 0 and 1,
@dbmessina
dbmessina / main.dart
Last active November 8, 2023 17:47
Colored boxes 2
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
@dbmessina
dbmessina / main.dart
Created June 30, 2023 03:39
Colored boxes
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
@dbmessina
dbmessina / main.dart
Last active June 28, 2023 18:20
EventModel
void main() {
// Tag an event from somewhere in the app
var event = EventModel(eventAction: "App Opened");
postAnalyticsDetails(event);
}
// Treat all of the optional parameters like feedbackRating if we want to pass empty string
// or like feedbackMaxRating if it turns out we need to provide null for optional parameters
class EventModel {
EventModel({