Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Flutterの Bottom Navigation による画面遷移について
Search
txmn
August 28, 2018
Programming
6.1k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Flutterの Bottom Navigation による画面遷移について
Flutter Meetup Tokyo #4 の初心者枠LT
txmn
August 28, 2018
Transcript
13 slides
Flutterの Bottom Navigation による画面遷移について Flutter Meetup Tokyo #4 Beginner Lightning
Talk
About Me • txmn / Haruki Watanabe • 株式会社フォニム •
サーバーサイドエンジニア(Rails) • フロントでReactやVue使ったり… • 既存WEBサービスのスマホアプリを作りたい • スマホアプリ開発経験無し • 一瞬 React Native x Expo に寄り道してFlutterへ • UdacityのGoogle公式のコースで学習。ちょうど1週間くらい。 Twitter
Bottom Navigation を実装したい! https://material.io/design/components/bottom-navigation.html
Navigator class でとりあえずやってみる Push pushReplacement •
Navigator.popで戻れる • “<” が自動でつく(下図参照) • 一方通行 • とりあえずこっち使うか…
しかし… たくさん問題があります • その都度新しいWidgetをbuildすることの負担 • 特にWidget内部でAPIを用いる場合など • タブ切り替え時にWidget内部の状態を維持して おきたい •
Twitterなどメジャーなアプリと同様 • 遷移時の挙動がMaterial Design ガイドラインに 反する • “ Don’t. Avoid using lateral (left-and-right) motion to transition between views.”
解決策をググってみる https://github.com/bizz84/nested-navigation-demo-flutter ありがとうございます
じっさいにやってみる 左図のようなアプリを考える • Scaffold • body • それぞれのtab itemに対応するWidget •
TabNavigator(※custom widget) • bottomNavigationBar • items 1. Home 2. Search 3. Bookmark 4. Message 5. Account
Step 1 : building all and offstage
• それぞれのタブに対応するWidget(以下①)を全て生成する • この時、①内部でも基本的にNavigatorを使うことになるので、アプリ全体で一意に Navigatorを定めるためにGlobalKey<NavigatorState>を①に流し込む • 変数currentTabの初期値をhomeに設定する • Offstage class を用いてcurrentTab以外の全てのタブをoffstageにする • Offstage(offstage: bool) で隠すことが出来る。 • cssのdisplay:none的な感じ。ちなみにoffstage(n:舞台裏)
Step 2 : stacking all • Step 1で作成したそれぞれのタブに対応するWidgetを全て1つに重ねる • Stack
Classでラップするだけで良い
Step 1, 2のそれぞれのコード部分抜粋 主にOffstageとNavigator key部分 Stackと①全生成について
Step 3 : Android back button handler • iOSには無いがAndroidにはback buttonがある
• そこでユーザーがpop先のRouteを 失った時に備えて、WillPopScope Classを用いて、事前にコールバック 先を登録しておく
実際の画面
まとめ • 非表示のWidgetをStackで重ねておいて、タブ選択時に表示をする というのはとても新鮮でした。 • iOS/AndroidのネイティブAppではどのようにBottom Navigationの 遷移を対応しているのか非常に気になりました。 • 拙い発表でしたが、最後までご清聴頂きありがとうございました。
Other Decks in Programming
See All in Programming
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
15
12k
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
300
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
200
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
400
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
350
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
440
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
360
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
390
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.6k
Kotlin Fest 2026: Kotlin コンパイラに Contribute してみよう! - Kotlin/Wasm で深い再帰を書けるようにした話
ternbusty
1
400
正解の無い問題を 「できるだけ上手く」解く ヒューリスティックで感性を磨こう。〜現実課題をプログラミングで解きあうコミュニティについて〜
allegrogiken
0
110
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
Featured
See All Featured
Claude Code のすすめ
schroneko
67
230k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
410
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Language of Interfaces
destraynor
162
27k
Color Theory Basics | Prateek | Gurzu
gurzu
1
530
Typedesign – Prime Four
hannesfritz
42
3.2k