Flutterやろうよ!!! 5 (458レス)
前次1-
抽出解除 レス栞

77: デフォルトの名無しさん (ワンミングク MMc7-+wGC) [sage] 2024/06/14(金) 21:49:14.15 ID:3MJI3A89M(1) AAS
KotlinでFlutterを触りたい
145: デフォルトの名無しさん (ワッチョイ 9767-1+BE) [] 2024/06/16(日) 08:39:19.15 ID:u7far7aY0(1/2) AAS
>>139
139(2): デフォルトの名無しさん (スップ Sd5a-kQwx) [sage] 2024/06/16(日) 04:36:28.60 ID:VstQa1y8d(1/5) AAS
これは恥ずかしい

import 'dart:async';

class A {
String str;
A(this.str);
}

void main() {
final sc = StreamController(sync: true);
sc.stream.listen((e) => print(e.str));

final a = A("StreamControllerに値の変更を検知する機能が!?");
sc.add(a);
a.str = "あります!";
a.str = "あるわけないだろdoc読めよwww";
sc.add(a);
}

>StreamControllerに値の変更を検知する機能が!?
>あるわけないだろdoc読めよwww
import 'dart:async';
class A {
A(this.str){
sc.add(str);
}
String str;
StreamController sc = StreamController()..stream.listen((newValue){
print(newValue);
});
void setAndNotify(String str){
this.str = str;
sc.add(str);
}
}
Future<void> wait() async {
await Future.delayed(Duration(seconds: 1));
}
void main() async {
final a = A('test');
await wait();
a.setAndNotify('test2');
await wait();
a.setAndNotify('test3');
await wait();
a.setAndNotify('test4');
}

Dart標準機能のStreamControllerで変更通知してますよね?
UI側はStreamBuilderが用意されているのでそれで変更検知できますよね。
Dart自体に用意されてないのにDartのサードパーティパッケージでできました、とか無いじゃん。
中を覗いたらDartでやってるんでしょ?
249: デフォルトの名無しさん (ワッチョイ a7f4-HpUb) [] 2024/07/02(火) 15:50:34.15 ID:uzy550Vj0(2/4) AAS
DartでResultをするうえで重要な点を言及していなかった。sealed class の機能があるからResultをする意味が上がる。

sealed class Result<V,E>{...}
final class Success<V,E> extends Result<V,E>{...}
final class Failure<V,E> extends Result<V,E>{...}

switch (result) {
Success():...;
Failure():...;
}

seald class の機能を使えばswitchでSuccessの場合とFailureの場合を強制できる。おれ個人は関数的な書き方ではなく文的な書き方を常用している。理由はreturn文をかけるから(早期returnができる)。ついでにexceptionもこのselad classを使う。

/// {@macro HttpRespons401Exception}
/// {@macro HttpRespons402Exception}
/// ...
sealed class HttpResponsException {...}
/// {@template HttpRespons401Exception}Unauthorized...{@endtemplate}
final class HttpRespons401Exception extends HttpResponsException {...}
/// ...
final class HttpRespons402Exception extends HttpResponsException {...}
/// ...
final class HttpRespons403Exception extends HttpResponsException {...} ...

switch (httpResponsException) {
HttpRespons401Exception():...;
HttpRespons402Exception():...;...
}

final Result<String, HttpResponsException> myHttpGetResult = myHttpGet(...);

厳密ではないが、おれはこんな感じで書いてるよというイメージ。DocCommentをつければmousehoverしたときに詳細がわかる。
288: デフォルトの名無しさん (ワッチョイ 9f01-i1i6) [sage] 2024/08/22(木) 00:50:46.15 ID:mmy1OEBC0(1) AAS
わいもWebアプリでええやんて思うけど
若者に見せるとアプリないの?て言われるんだよねぇ
313: デフォルトの名無しさん (ワッチョイ fb82-NuqX) [sage] 2024/10/31(木) 17:21:59.15 ID:RUtpzVgq0(1) AAS
俺も同じ印象だな
何故なんだろう
456: デフォルトの名無しさん (ワッチョイ 8101-o0Wv) [] 2025/06/15(日) 09:03:17.15 ID:w464Pqf30(1) AAS
Flutter陣営のLiquid Glassの試みは既にはじまってた
外部リンク:github.com
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 1.114s*