Flutterやろうよ!!! 5 (483レス)
Flutterやろうよ!!! 5 http://mevius.5ch.net/test/read.cgi/tech/1714961291/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
レス栞
リロード規制
です。10分ほどで解除するので、
他のブラウザ
へ避難してください。
139: デフォルトの名無しさん (スップ Sd5a-kQwx) [sage] 2024/06/16(日) 04:36:28.60 ID:VstQa1y8d これは恥ずかしい 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 http://mevius.5ch.net/test/read.cgi/tech/1714961291/139
142: デフォルトの名無しさん (ワッチョイ 7f1c-JH9N) [] 2024/06/16(日) 07:03:25.45 ID:IDEikgiG0 >>139 なんでおれが君のコードの添削せなあかんねん。 だから、ただの変数に別の値を代入しても検知しないって何度も言ってるやろ。 class A { String str; A(this.str); } a.str = "あります!"; a.str = "あるわけないだろdoc読めよwww"; main method で StreamCotroller の instance 作成してるけど、この class A は StreamController と全く関係ないから class A の property である str に別の値を代入したところで検知するわけないやろ? 二度とコード書くな。 http://mevius.5ch.net/test/read.cgi/tech/1714961291/142
145: デフォルトの名無しさん (ワッチョイ 9767-1+BE) [] 2024/06/16(日) 08:39:19.15 ID:u7far7aY0 >>139 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でやってるんでしょ? http://mevius.5ch.net/test/read.cgi/tech/1714961291/145
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.027s