๊ตฌํ ๋ชฉํ ๐ง
ํ๋จ๋ฒํผ์ด ํค๋ณด๋์ ๊ฐ๋ ค์ง์ง ์๊ฒ ์ฌ์ง๊ณผ ๊ฐ์ด ํค๋ณด๋ ๋์ด์ ๋ง์ถฐ ๋ฒํผ์ ์ฌ๋ ค๋ณด์. ์๋ ์ค๋ช ์ ์ดํด๋ฅผ ๋๊ธฐ์ํด ๊ฐ๋จํ ์์ ์ฝ๋๋ก ์งํํด๋ณด์๋ค.
bottomNavigationBar: SafeArea(
child: ElevatedButton(
onPressed: () {},
child: Text("๋ค์"),
),
),
ํ์ฌ ์ฝ๋๋ ๋ค๋น๊ฒ์ด์ ๋ฐ์ ๋ฒํผ์ ๋ฐฐ์นํ๊ณ SafeArea ์ฌ๋ฐฑ๋ง ์ฃผ๊ณ ์์ ๋ฟ ํค๋ณด๋๊ฐ ์ฌ๋ผ์๋ฒ๋ฆฌ๋ฉด ๊ทธ๋๋ก ๋ฒํผ์ ๊ฐ๋ฆฌ๊ฒ ๋์ด๋ฒ๋ฆฐ๋ค. ์ฌ๊ธฐ์ MediaQuery.of(context).viewInsets.bottom์ ์ฌ์ฉํ๋ฉด ํค๋ณด๋ ๋์ด๋ฅผ ๊ฐ์งํ์ฌ ๋ฒํผ์ ์๋์ผ๋ก ์ฌ๋ฆด ์ ์๋ค.
bottomNavigationBar: AnimatedPadding(
duration: Duration(milliseconds: 100),
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: SafeArea(
child: ElevatedButton(
onPressed: () {},
child: Text("๋ค์"),
),
),
),
โ
1. ํค๋ณด๋ ๋์ด ์๋ ๊ฐ์ง → MediaQuery.of(context).viewInsets.bottom
โ
2. ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
์ ์ฉ → AnimatedPadding ์ฌ์ฉ
โ
3. SafeArea ์ ์ฉ → iPhone ๋
ธ์น & Android ํ ๋ฐ ๋์
์์ฝ๋์์ viewInsets์ ์ฌ์ฉํ๊ณ ์๋๋ฐ ์ด์๋ํ ์์ธํ ์ค๋ช ์ ์ ๋ธ๋ก๊ทธ์์ ๋๋ฌด ์น์ ํ๊ณ ์์ธํ๊ฒ ์ค๋ช ํ๊ณ ์๋ค. ํ์ค์์ฝํ์๋ฉด viewInsets์ ํ๋ฉด์ด ๊ฐ๋ ค์ง๋ ๋ถ๋ถ์ ์ด์ผ๊ธฐํ๋ค. viewInsets.bottom์ ํ๋ฉด ์๋์ชฝ ๊ฐ๋ ค์ง๋ ๋์ด, ์ฆ ํค๋ณด๋์ ์ํด ๊ฐ๋ ค์ง๋ ๋์ด๋ฅผ ๋์ ์ผ๋ก ๊ฐ์ ธ์ค๋ ์์ฑ์ด๋ผ๊ณ ํ ์ ์๋ค.
AnimatedPadding ์ผ๋ก ์ฌ๋ฐฑ ๋ณ๊ฒฝ ์ฝ๋๋ฅผ ๋ฉํํ๋ฉด padding(์ฌ๋ฐฑ)์ด ๋ณ๊ฒฝ๋ ๋ ์ ๋๋ฉ์ด์ ํจ๊ณผ๋ฅผ ์ ์ฉํด์ค ์ ์๋ค.
'Flutter' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Riverpod ๊ณต์๋ฌธ์ ์ฝ์ด๋ณด๊ธฐ (1) Make your first provider/network request (0) | 2025.03.10 |
---|---|
Flutter์์ ๋๋กญ๋ค์ด ๋ฉ๋ด ๊ตฌํํ๊ธฐ (0) | 2025.03.07 |
bloc ์ํ๊ด๋ฆฌ์์ forEach์ onEach์ ์ฐจ์ด์ (0) | 2025.03.04 |
ํ๋ฌํฐ์ ์ง์ญํ ๊ธฐ๋ฅ ๋ฃ์ด์ฃผ๋ ๋ฐฉ๋ฒ (1) | 2025.03.03 |
๋ค๋ฅธ ios ๊ณ์ ํ๋ก์ ํธ์ ๋ด ์์ดํฐ ๊ธฐ๊ธฐ ๋ฑ๋กํ๊ธฐ (0) | 2025.03.01 |