class MyClass {
...
String interestingMethod() {
return 'Foo';
}
}
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:web_socket_channel/web_socket_channel.dart'; | |
class SomeClass { | |
// Contains message history | |
final _messages = <String>[]; | |
late final WebSocketChannel _channel; | |
void createConnection() { | |
// Connect to web socket | |
_channel = WebSocketChannel.connect(Uri.parse('ws://localhost:8080/ws')); |
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:io'; | |
import 'package:shelf_plus/shelf_plus.dart'; | |
void main() => shelfRun(init); | |
Handler init() { | |
var app = Router().plus; | |
// Track connected clients |
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:io'; | |
import 'package:shelf_plus/shelf_plus.dart'; | |
void main() => shelfRun(init); // runs server with hot-reload preconfigured | |
Handler init() { | |
var app = Router().plus; | |
app.get('/', () => 'Hello World!'); |
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'; | |
// #begin | |
class MyClass { | |
// #skip | |
int someMethod() { | |
return Random().nextInt(1); | |
} | |
// #resume |
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
[Unit] | |
Description=dartbackend | |
[Service] | |
User=root | |
Type=simple | |
ExecStart=/usr/bin/dart bin/dart_backend.dart | |
WorkingDirectory=/root/dart_backend | |
Restart=always | |
RestartSec=5s |
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:convert'; | |
import 'dart:io'; | |
import 'package:alfred/alfred.dart'; | |
void main() async { | |
var app = Alfred(); | |
app.get('*', (req, res) => Directory('public')); |
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:io'; | |
import 'package:alfred/alfred.dart'; | |
void main() async { | |
var app = Alfred(); | |
app.get('*', (req, res) => Directory('public')); | |
await app.listen(8080); | |
} |
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'; | |
import 'package:simple_animations/simple_animations.dart'; | |
/* | |
environment: | |
sdk: '>=2.12.0 <3.0.0' | |
dependencies: | |
flutter: | |
sdk: flutter |
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
var name = StateProvider((_) => "Peter"); | |
var age = StateProvider((_) => 32); | |
// Combines "name" and "age" to a String | |
var greeting = Provider<String>((scope) { | |
return "Hi! My name is ${scope.watch(name).state} and " | |
"I am ${scope.watch(age).state} years old."; | |
}); | |
// Refines the "greeting" String to a Widget |
NewerOlder