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 Foundation | |
protocol AProtocol { | |
func printIsMainThread() | |
} | |
struct AStruct: AProtocol { | |
@MainActor | |
func printIsMainThread() { | |
print("(struct) isMainThread=\(Thread.isMainThread)") |
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 Combine | |
import SwiftUI | |
struct ContentView: View { | |
@StateObject var observable = OuterObservable() | |
var body: some View { | |
VStack { | |
Display(title: "inner", value: observable.inner.binding(\.value)) | |
Display(title: "outer", value: $observable.value) |
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/foundation.dart'; | |
class InfiniteListPage<T> { | |
final List<T> items; | |
final int totalCount; | |
InfiniteListPage(this.items, this.totalCount); | |
} | |
class InfiniteListController<T> extends ChangeNotifier { |
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'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override |
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:typed_data'; | |
import 'dart:ui'; | |
const _BYTES_PER_PIXEL = 4; | |
class ImageEditor { | |
final int imageWidth; | |
final int imageHeight; | |
final ByteData _byteData; |
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
class PositionedOverlayEntry extends StatefulWidget { | |
final OverlayState overlay; | |
final Widget child; | |
final double? left; | |
final double? top; | |
final double? right; | |
final double? bottom; | |
final double? width; | |
final double? height; |
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:mime/mime.dart'; | |
void main(List<String> arguments) async { | |
const port = 8080; | |
var lastId = (await _loadLastId()) ?? -1; | |
final server = await HttpServer.bind(InternetAddress.anyIPv4, port); | |
server.listen((request) async { | |
void close(int statusCode) { | |
request.response.statusCode = 404; |
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
/** | |
* Script to replace localized text on the page (any element with the data-loc-key attribute) | |
*/ | |
function replaceLocalizedText(locObject) { | |
document.querySelectorAll('[data-loc-key]').forEach(function(textElement){ | |
const locKey = textElement.getAttribute('data-loc-key'); | |
textElement.innerHTML = locObject[locKey]; | |
}); |