Skip to content

Instantly share code, notes, and snippets.

View esDotDev's full-sized avatar

Shawn esDotDev

  • esDot Studio Inc
  • Edmonton, AB
View GitHub Profile

import 'package:flutter/material.dart';

void main() { runApp(SomeWidget()); }

class SomeWidget extends StatefulWidget { @override State createState() => SomeWidgetState(); }

@esDotDev
esDotDev / main.dart
Last active August 10, 2023 15:49
flying-neutron-5516
mport 'package:flutter/material.dart';
void main() { runApp(SomeWidget()); }
class SomeWidget extends StatefulWidget { @override State createState() => SomeWidgetState(); }
class SomeWidgetState extends State { int count = 0;
void incrementCount() => setState(() => count++);
@esDotDev
esDotDev / ReactFlashCardGame.ts
Last active December 8, 2022 20:34
Build a flash card game in React to help learn basic addition. It should show a series of 10 questions, one at a time. When all 10 questions have been answered, it should have a game over view showing their score and a button to restart the game.
import React, {useState, useEffect} from 'react';
const FlashCardGame = () => {
const [score, setScore] = useState(0);
const [quesNum, setQuesNum] = useState(0);
const [questions, setQuestions] = useState([]);
useEffect(() => {
generateQuestions();
// Controller
class TodoController {
constructor(api) {
this.api = api;
}
async getAllTodos() {
const todos = await this.api.getAllTodos();
return todos;
}
@esDotDev
esDotDev / ChatGPT_TodoApp.dart
Created December 8, 2022 19:51
Write a TODO app in FLutter using a Rest API to read and write data. Encapsulate business logic in a dedicated controller class.
Write a TODO app in FLutter using a Rest API to read and write data. Encapsulate business logic in a dedicated controller class.
//Imports
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
//Todo Controller class
class TodoController {
//Get all todos
#!/bin/bash
flutter clean
rm -rf $FLUTTER_ROOT/.pub-cache
rm -rf $HOME/Library/Caches/CocoaPods
rm -rf ios/Pods
rm -rf ios/build
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/
rm -rf ~/Library/Caches/com.apple.dt.Xcode/
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
/// Click the content to expand / constact the card.
/// These overflow warnings are not helpful, and impact developer efficiency and joy.
// It would be nice to turn them off for this specific widget.
void main() {
runApp(MyApp());
}
import 'dart:math';
import 'package:flutter/material.dart';
int _seed = DateTime.now().millisecondsSinceEpoch;
/// Globally accessible instance of `Random`.
/// Makes using random values as easy as `rnd(20)` or `rnd.getBool()`.
Random rnd = Random(_seed);
/// Sets the seed of the `rnd` global `Random` instance.
@esDotDev
esDotDev / state_view_pattern.dart
Last active August 5, 2023 12:52
Shows a simple way to separate logic and ui code using a `StatefulWidget` + a private `StatelessWidget`.
/// 1. The public facing widget, configuration options live here
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
/// 2. The state / controller / bloc / view controller
/// event handlers and helper methods can live here
class _MyWidgetState extends State<MyWidget> {
void _handlePressed() => print('todo');
@override
class Benchmark extends StatefulWidget {
const Benchmark({Key? key}) : super(key: key);
@override
_BenchmarkState createState() => _BenchmarkState();
}
class _BenchmarkState extends State<Benchmark> {
double _tweenSliderValue = .2;
bool _enableRendering = false;
bool _useGTween = false;