Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Flutter with Redux
Search
木藤紘介/Kosuke Kito
December 06, 2018
Programming
3
1.2k
Flutter with Redux
in REQU (
https://requ.ameba.jp/
)
Qiitaはこちら
https://qiita.com/kitoko552/items/155baf852b059550b0f9
木藤紘介/Kosuke Kito
December 06, 2018
Tweet
Share
More Decks by 木藤紘介/Kosuke Kito
See All by 木藤紘介/Kosuke Kito
iOS de Redux
kitoko552
1
88
Other Decks in Programming
See All in Programming
Benchmark
sysong
0
270
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
590
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
520
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
230
Modern Angular with Signals and Signal Store:New Rules for Your Architecture @enterJS Advanced Angular Day 2025
manfredsteyer
PRO
0
150
Julia という言語について (FP in Julia « SIDE: F ») for 関数型まつり2025
antimon2
3
980
20250613-SSKMvol.15
diostray
0
100
Composerが「依存解決」のためにどんな工夫をしているか #phpcon
o0h
PRO
1
240
Deep Dive into ~/.claude/projects
hiragram
10
1.9k
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
460
VS Code Update for GitHub Copilot
74th
1
470
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
250
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
329
21k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Done Done
chrislema
184
16k
The Language of Interfaces
destraynor
158
25k
Designing for Performance
lara
609
69k
Thoughts on Productivity
jonyablonski
69
4.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
The Cult of Friendly URLs
andyhume
79
6.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
17
950
Transcript
Flutter with Redux -REQUͷ߹
౻ߛհ Kosuke Kito @kitoko552 REQU by CyberAgent, Inc. iOS/Swift, Flutter/Dart
Ωϟϯϓข͖ՐεϚϒϥཉ͍͠
https://requ.ameba.jp/
- Unidirectional data flow - Three principles Redux
Unidirectional data flow View Store Reducer State Reducer State Reducer
State Action Middleware Subscribe Dispatch
- Single source of truth - State is read-only -
Changes are made with pure functions Three principles
- ΞϓϦέʔγϣϯશମͷঢ়ଶΛ1ͭͷStoreͰදݱ - ঢ়ଶΛม͔͑ͨͬͨΒ৽͍͠State࡞ͬͯ͘Ε - ঢ়ଶมߋͰ͖ΔͷReducer͚ͩ Three principles
FlutterͰRedux
None
redux:͖ͬ͞ͷͭ flutter_redux: reduxͱWidgetπϦʔͷհ redux_logging: ϩά redux_thunk: ThunkMiddlewareΛఏڙ REQUͷ߹
ThunkMiddleware? View Store Reducer State Reducer State Reducer State Action
Middleware Subscribe Dispatch ThunkMiddleware
ඇಉظॲཧΛActionͱͯ͠ఆٛͰ͖ΔΑ͏ʹ͢ ΔͨΊͷMiddleware ThunkMiddleware?
REQUͷ߹ʢActionʣ class UpdateSomething { UpdateSomething(this.id, this.name); final int id; final
String name; } store.dispatch(UpdateSomething(id, name));
REQUͷ߹ʢActionʣ ThunkAction<AppState> fetchSomething() { return (store) { // ඇಉظॲཧ .then((response)
=> store.dispatch(UpdateSomething(response))) .catchError((error) => store.dispatch(UpdateError(error))); }; } store.dispatch(fetchSomething());
REQUͷ߹ʢViewʣ class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context)
{ return StoreConnector<AppState, _HomePageViewModel>( distinct: true, converter: (store) { return _HomePageViewModel( name: store.state.homeState.name, onTap: () => store.dispatch(UpdateName('Next name')), ); }, builder: (context, viewModel) { return Scaffold( body: Center( child: FlatButton( onPressed: viewModel.onTap, child: Text(viewModel.name), ), ), ); }, ); } }
REQUͷ߹ʢViewʣ View Store Reducer State Reducer State Reducer State Action
Middleware Subscribe Dispatch View Model
REQUͷ߹ʢStateʣ @immutable class HomeState { HomeState({@required this.name}); final String name;
HomeState copyWith({String name}) { return HomeState(name: name ?? this.name); } }
REQUͷ߹ʢReducerʣ final Reducer<HomeState> homeReducer = combineReducers<HomeState>([ TypedReducer(_updateName), ]); HomeState _updateName(HomeState
state, UpdateName action) { return state.copyWith(name: action.name); }
- ςετ͕ෆࣗવͳॻ͖ํʹͳΔͱ͜Ζ͕͋Δ - Action͕ଠΓ͕ͪ - AnimatedListͱͷ૬ੑ͕ྑ͘ͳ͍߹͕͋Δ ΜͰ͍Δͱ͜Ζ
- దͳϧʔϧͰറΕΔ =>νʔϜϝϯόʔ୭͕ॻ͍ͯ͋Δఔಉ͡Α͏ͳ࣮ʹͳΔ - FlutterReduxΒͳ͍৽ϝϯόʔʹͱֶͬͯशίετ͕ ߴͯ͘ࠅ - iOSΑΓFlutterͷํ͕૬ੑ͍͍ ײ