Skip to content

Instantly share code, notes, and snippets.

import 'dart:math' as math;
import 'package:flutter/material.dart';
class DropExtraChildren extends StatelessWidget {
final double spacing;
final List<Widget> children;
const DropExtraChildren({
super.key,
required this.spacing,
import 'package:flutter/material.dart';
class DropExtraChildren extends StatelessWidget {
final Axis direction;
final double spacing;
final List<Widget> children;
const DropExtraChildren({
super.key,
this.direction = Axis.horizontal,

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.