Dart で Unix domain socket 通信する

Dart で Unix domain socket やっていきます. Support making HTTP requests through unix sockets · Issue #42716 · dart-lang/sdk Dart Version: Dart VM version: 2.8.4 (stable) on "macos_x64" I'd like to interact with the Docker … github.com

Emacs lsp-dart で fvm を使う

重い腰を上げて fvm をしっかり使うようにしました. ちなみに似たような雰囲気のある issue があり,snap で Dart をインストールした場合に sdk-dir を認識できていないような感じです.

Angular Dart をシングルバイナリで動かす

テンプレートをさくっと作成. $ dart create -t server-shelf foo $ cd foo $ ngdart create web とりあえず shelf を動かしてみるとこんな感じ. $ dart bin/server.dart Server listening on port 8080 2022-03-27T09:27:03.905499 0:00:00.014259 GET [200] / 2022-03-27T09:27:09.375476 0:00:00.005037 GET [200] /echo/foo--- $ curl http://localhost:8080/ Hello, World! $ curl http://localhost:8080/echo/foo foo 次に Angular Dart の方を build して動かしてみます.

Dart で ASCII テーブルフォーマットで出力するライブラリを作った

go-lang の tablewriter 的な ASCII テーブルで表示するやつが欲しかったの作りました. tabler | Dart package This library is displaying tabular data in ASCII table format. pub.dev example のとおりですが,こんな感じで使えます.

shelf を利用した Dart frontend を試す

backend はこちら. Dart backendを試す memo.yuzumone.net Flutter Web とか AngularDart などあるんですけどちょっと雑にやりたいという場合です. コードは下記の通り. const index = '''<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> <title>Hello, world!</title> </head> <body> <main role="role"> <div class="container"> <h1 class="mt-5">{{ title }}</h1> </div> </main> </body> </html>'''; void main(List<String> args) async { var handler = const shelf.Pipeline() .addMiddleware(shelf.logRequests()) .addHandler(_echoRequest); var server = await io.serve(handler, _hostname, port); print('Serving at http://${server.address.host}:${server.port}'); } Future<shelf.Response> _echoRequest(shelf.Request request) async { var template = Template(index); var output = template.renderString({'title': 'hoge'}); var headers = {'content-type': 'text/html'} return shelf.Response.ok(output, headers: headers); } index.html を静的ファイルで用意するのが普通だと思うんですが,dart compile して動かしてみたかったので dart ファイルに収めました. go-bindata などのように executable に静的ファイルを include するような仕組みが Dart にもあるといいですね. 気が向いたら作りたい.

Dart の null safety にマイグレーションする

いよいよ Dart の null safety が stable となりました. これまで何回か紹介しているライブラリ ipaddr を null safety にしていく過程をメモしておきます. 参考までに pullrq は下記です. Sound null safety by yuzumone · Pull Request #27 · yuzumone/ipaddr Dart library for using to create/poke/manipulate IPv4 and IPv6 addresses and networks. - Sound null … github.com

Dart backend を試す

Flutter には盛り上がりがみられる Dart でバックエンドもやってみました. この時気になるのがフレームワークどうするか問題ですね. メジャーどころは下記の 2 つです.

Dart における RSA を使用した秘密鍵での暗号化

どうしても RSA Private key を使用して署名をしなきゃいけない案件があったのでやりました. 使用したライブラリは下記です. 死ぬほど助かりました. encrypt | Dart package A set of high-level APIs over PointyCastle for two-way cryptography. pub.dev

sembast を試す

Flutter でモバイルだけでなくデスクトップや Web などマルチプラットフォームに対応している NoSQL データベースライブラリ sembast を使ってみたのでメモ. sembast | Dart package NoSQL persistent embedded file system document-based database for Dart VM and Flutter with … pub.dev

Dart で ipaddress をいい感じにするライブラリを作った

Dart で ipaddress をいい感じにするライブラリを作りました. GitHub - yuzumone/ipaddr: Dart library for using to create/poke/manipulate IPv4 and IPv6 addresses and networks. Dart library for using to create/poke/manipulate IPv4 and IPv6 addresses and networks. - … github.com ipaddr | Dart package This library is used to create/poke/manipulate IPv4 and IPv6 addresses and networks. pub.dev