This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of using Dart 3 switch expression | |
void main() { | |
print("code: ${process('ok')}"); | |
} | |
Code process(String res) { | |
return switch(res) { | |
"ok" => Code.ok, | |
"error" => Code.ok, | |
_ => Code.undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "dart:math"; | |
// Example of use Dart's "late final" lazily initialised cached async value | |
void main() async { | |
late final Future<int> magicNumber = Future.value(Random().nextInt(100)); | |
print("1. magic number:${await magicNumber}"); | |
print("2. magic number:${await magicNumber}"); | |
print("3. magic number:${await magicNumber}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "dart:math"; | |
// Example of use Dart's "late final" lazily initialised cached value | |
void main() { | |
late final int magicNumber = Random().nextInt(100); | |
print("1. magic number:$magicNumber"); | |
print("2. magic number:$magicNumber"); | |
print("3. magic number:$magicNumber"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef Callback = Object Function(); | |
void main() async { | |
final res = request(false); | |
final mesg = switch (res) { | |
OkResponse() => "houston we are ok", | |
ErrResponse() => "houston we have a problem" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
// Updated to Flutter 3 by @maks | |
// original from: https://gist.github.com/rodydavis/5c7b3365ba9c4b010cace84ca20c2bcc | |
const kTabletBreakpoint = 720.0; | |
const kDesktopBreakpoint = 1200.0; | |
const kSideMenuWidth = 250.0; | |
class AdaptiveScaffold extends StatelessWidget { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By PixelToast | |
var src = | |
"mov r0, #69\n" | |
"bx lr\n" | |
"ldmedeq ip!, {a3-sp}\n" | |
"strbhi r13, [v2, lr, asr #3]!\n" | |
"ldrls a3, [sb], sp, asr #0x14\n"; | |
main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
// example code from: https://stackoverflow.com/a/70236525/85472 | |
// This is the type used by the popup menu below. | |
enum Menu { itemOne, itemTwo, itemThree, itemFour } | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[graphics] | |
fullscreen=false | |
use_gpu=true | |
idle_ms=20 | |
[keyboard] | |
key_up=82 | |
key_left=80 | |
key_down=81 | |
key_right=79 | |
key_select=225 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Usage: | |
# ./firetron <name> <url> | |
# ./firetron hulu hulu.com | |
firefox -CreateProfile "$1" | |
cd "$HOME/.local/share/icons/hicolor/32x32/apps/" || exit | |
wget -O $1.png $2/favicon.ico | |
touch "$HOME/.local/share/applications/$1.desktop" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:isolate'; | |
import 'dart:typed_data'; | |
import 'package:libao/libao.dart'; | |
void playbackWorker(SendPort replyPort) { | |
final requestsPort = ReceivePort(); | |
final player = AudioPlayer(); | |
player.play(); |
NewerOlder