Flutter狀態State的5種應對方法

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"本文最初發佈於poetryincode.dev網站,經原作者授權由InfoQ中文站翻譯並分享。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"點擊這裏查看本文中示例的代碼。("},{"type":"link","attrs":{"href":"https:\/\/github.com\/chimon2000\/flutter_state_five_ways","title":"","type":null},"content":[{"type":"text","text":"https:\/\/github.com\/chimon2000\/flutter_state_five_ways"}]},{"type":"text","text":")"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不管你是剛開始瞭解Flutter,還是已經接觸Flutter有了一段時間,你都可能已經知道有很多方法可以處理應用程序狀態。我可以肯定,每個月都會冒出來一些新的途徑。因爲沒有太多可以直接對比的例子,所以想要了解這些方法之間的差異和各自的權衡可能會很困難。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我認爲,學習如何使用一個庫的最佳方法是用它來構建項目。對比兩個庫的最佳方法是用它們來執行相同的任務:構建相同的功能,從而更好地瞭解彼此的權衡所在。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在本文中,我將使用同樣的應用程序作爲基礎,用我很喜歡的幾位作者製作的5個庫,使用相同的模式來實現共享狀態。這些庫有的很流行,有的罕見,有的很新,有的相對老舊。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":1,"normalizeStart":1},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"Riverpod(帶有StateNotifier)"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":"Bloc"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":"flutter_command"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":4,"align":null,"origin":null},"content":[{"type":"text","text":"MobX"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":5,"align":null,"origin":null},"content":[{"type":"text","text":"binder"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我會盡力找出各個庫之間的差異,並對每種方法做一個總結。爲了演示各個庫的API,我們將實現一個筆記應用,它會顯示一個輸入字段以創建新的筆記,還會顯示已創建筆記的列表。你可以在這裏觀看演示效果("},{"type":"link","attrs":{"href":"https:\/\/flutter-state.codemagic.app\/","title":"","type":null},"content":[{"type":"text","text":"https:\/\/flutter-state.codemagic.app\/"}]},{"type":"text","text":")。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章