์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- ์๋ฐ์ด๋ณด
- db
- JavaScript
- RESTful API
- Android
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- ํ์ด์ฌ๊ณต๋ถ
- ์คํธ๋ฆผ๋ฆฟ ๊ธฐ๋ณธ
- ํ๋ค์ค๊ณต๋ถ
- java
- ์๋๋ก์ด๋ ์ฑ ๊ฐ๋ฐ
- Flutter
- ์๋ฐ๊ธฐ์ด
- REACT
- ์๋ฐ๊ณต๋ถ
- serverless
- ์๋ฐ์คํฌ๋ฆฝํธ
- ํ์ด์ฌ
- MySQL
- ์๋ฐ
- ์คํธ๋ฆผ๋ฆฟ
- ์๋ฐ์คํฌ๋ฆฝํธ ๊ณต๋ถ
- ์๋ฐํ๋ก๊ทธ๋๋ฐ
- ์๋๋ก์ด๋ ์คํ๋์ค
- Pandas
- ํ๋ค์ค
- Streamlit๊ธฐ์ด
- ์น๋์๋ณด๋ ์ ์
- ์น๋์๋ณด๋ ๊ธฐ์ด
- streamlit
- Today
- Total
ruriruriya
[Flutter] ํ๋ฌํฐ ์น๋ทฐ ๋ค๋ก๊ฐ๊ธฐ ๊ธฐ๋ฅ ๊ตฌํ(webview_flutter) ๋ณธ๋ฌธ
[Flutter] ํ๋ฌํฐ ์น๋ทฐ ๋ค๋ก๊ฐ๊ธฐ ๊ธฐ๋ฅ ๊ตฌํ(webview_flutter)
๋ฃจ๋ฆฌ์ผใ 2025. 5. 12. 17:47
์น๋ทฐ ์ฑ์ ๋ง๋ค๋ฉด ๋ค๋ก๊ฐ๊ธฐ ๋ฒํผ์ ๋๋ฅผ ๋ ์ฑ์ด ๊บผ์ง๋ ํ์์ด ๋ฐ์ํ๋ค.
๊ทธ๋ด ๋ ์ฑ ๊ฐ๋ฐ ์ชฝ์์ ์ปจํธ๋กค์ ํด์ค์ผ ํ๋ค.
ํ๋ฌํฐ๋ก ๊ทธ๋ ๊ฒ ์ปจํธ๋กค ๊ธฐ๋ฅ ๊ตฌํํ์ฌ ๊ธฐ๋กํ๋ค.
ํ์ง๋ง iOS๋ ๋ค๋ก๊ฐ๊ธฐ ์ค์์ดํ ๊ธฐ๋ฅ์ด ์๋๋ฐ webview_flutter ํจํค์ง์์๋ ๊ตฌํ์ ํ์ง ๋ชปํ๋ค.
InAppWebView๋ก๋ ๊ตฌํ์ด ๊ฐ๋ฅํ๋ค๋ ๋ฐ ๋ค์์ InAppWebView๋ก ์น๋ทฐ๋ฅผ ๊ตฌํํด์ ํด๋ด์ผ๊ฒ ๋ค.
0. ์น๋ทฐ ๊ตฌํํ๊ธฐ
https://ruriruriya.tistory.com/270
[Flutter] ํ๋ฌํฐ ์น๋ทฐ ์ฑ ๋ง๋ค๊ธฐ (package:webview_flutter)
ํ๋ฌํฐ๋ก ์น๋ทฐ ์ฑ์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ! ๋ ธ์น์ ์ํ๋ฐ ๋ถ๋ถ SafeArea๋ก ์ฒ๋ฆฌํด์ ํธ์ํ๊ฒ ๋ณผ ์ ์๋๋ก ํ๋ค.0. ํ๋ก์ ํธ ์์ฑ์ ์๋ต.. 1. ์น๋ทฐ ํ๋ฌ๊ทธ์ธ(webview_flutter) ์ถ๊ฐ - pubspec.yaml์๋์ ๊ฐ์ด depen
ruriruriya.tistory.com
1. ์๋๋ก์ด๋ ๋ค๋ก๊ฐ๊ธฐ ๋์ ํจ์ ์์ฑ
// ์๋๋ก์ด๋ ๋ค๋ก๊ฐ๊ธฐ ๋์ ํจ์
Future<bool> _onWillPop() async {
if (await _controller.canGoBack()) {
_controller.goBack(); // WebView ๋ด ๋ค๋ก๊ฐ๊ธฐ ์คํ
return false; // ์ฑ ์ข
๋ฃ ๋ฐฉ์ง
}
return true; // ๋ค๋ก ๊ฐ ํ์ด์ง ์์ผ๋ฉด ์ฑ ์ข
๋ฃ ํ์ฉ
}
2. WillPopScope ์์ ฏ์ผ๋ก WebView ๊ฐ์ธ๊ธฐ
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _onWillPop,
child: Scaffold(
backgroundColor: Colors.white,
resizeToAvoidBottomInset: true,
body: SafeArea(
child: WebViewWidget(controller: _controller),
),
),
);
}
3. ์ ์ฒด์ฝ๋
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter WebView App',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const WebViewExample(),
);
}
}
class WebViewExample extends StatefulWidget {
const WebViewExample({super.key});
@override
State<WebViewExample> createState() => _WebViewExampleState();
}
class _WebViewExampleState extends State<WebViewExample> {
late final WebViewController _controller;
@override
void initState() {
super.initState();
_controller = WebViewController()
..loadRequest(Uri.parse('https://flutter.dev'));
}
// ์๋๋ก์ด๋ ๋ค๋ก๊ฐ๊ธฐ ๋์ ํจ์
Future<bool> _onWillPop() async {
if (await _controller.canGoBack()) {
_controller.goBack(); // WebView ๋ด ๋ค๋ก๊ฐ๊ธฐ ์คํ
return false; // ์ฑ ์ข
๋ฃ ๋ฐฉ์ง
}
return true; // ๋ค๋ก ๊ฐ ํ์ด์ง ์์ผ๋ฉด ์ฑ ์ข
๋ฃ ํ์ฉ
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _onWillPop,
child: Scaffold(
backgroundColor: Colors.white,
resizeToAvoidBottomInset: true,
body: SafeArea(
child: WebViewWidget(controller: _controller),
),
),
);
}
}