์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- JavaScript
- java
- streamlit
- ํ์ด์ฌ๊ณต๋ถ
- ํ๋ค์ค
- db
- ์๋ฐ์คํฌ๋ฆฝํธ ๊ณต๋ถ
- Streamlit๊ธฐ์ด
- ์๋ฐ์คํฌ๋ฆฝํธ
- REACT
- ํ์ด์ฌ
- ์๋ฐํ๋ก๊ทธ๋๋ฐ
- ์๋ฐ๊ณต๋ถ
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- ์น๋์๋ณด๋ ์ ์
- ์คํธ๋ฆผ๋ฆฟ ๊ธฐ๋ณธ
- Flutter
- Pandas
- ์๋๋ก์ด๋ ์ฑ ๊ฐ๋ฐ
- ์น๋์๋ณด๋ ๊ธฐ์ด
- ์คํธ๋ฆผ๋ฆฟ
- MySQL
- serverless
- RESTful API
- ์๋๋ก์ด๋ ์คํ๋์ค
- ํ๋ค์ค๊ณต๋ถ
- ์๋ฐ๊ธฐ์ด
- ์๋ฐ์ด๋ณด
- ์๋ฐ
- Android
- Today
- Total
ruriruriya
[Flutter] ํ๋ฌํฐ ์น๋ทฐ ์ฑ ๋ง๋ค๊ธฐ (package:webview_flutter) ๋ณธ๋ฌธ
[Flutter] ํ๋ฌํฐ ์น๋ทฐ ์ฑ ๋ง๋ค๊ธฐ (package:webview_flutter)
๋ฃจ๋ฆฌ์ผใ 2025. 5. 12. 17:09ํ๋ฌํฐ๋ก ์น๋ทฐ ์ฑ์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ! ๋ ธ์น์ ์ํ๋ฐ ๋ถ๋ถ SafeArea๋ก ์ฒ๋ฆฌํด์ ํธ์ํ๊ฒ ๋ณผ ์ ์๋๋ก ํ๋ค.
0. ํ๋ก์ ํธ ์์ฑ์ ์๋ต
..
1. ์น๋ทฐ ํ๋ฌ๊ทธ์ธ(webview_flutter) ์ถ๊ฐ - pubspec.yaml
์๋์ ๊ฐ์ด dependencies ์ถ๊ฐํ๊ณ ํฐ๋ฏธ๋์์ pub get์ผ๋ก ํจํค์ง ์ถ๊ฐ
dependencies:
flutter:
sdk: flutter
webview_flutter: ^4.11.0 # (์ต์ ๋ฒ์ ํ์ธ)
2. ๋ค์ดํฐ๋ธ๋ณ ์ค์
2.1. Android
android/app/src/main/AndroidManifest.xml ์ ์ธํฐ๋ท ๊ถํ ์ถ๊ฐ
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
...
2.2. iOS
ios/Runner/Info.plist ์ ์๋ ๋ด์ฉ ์ถ๊ฐ
iOS ์ฑ์ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ณด์์์ ์ด์ ๋ก, ์ฑ์์ ์ ์ํ๋ ๋ชจ๋ ์น์ฌ์ดํธ๊ฐ HTTPS(์ํธํ๋ ํต์ )๋ฅผ ์ฌ์ฉํ๋๋ก ๊ฐ์ ํ๋ค.
์ด ์ ์ฑ
์ App Transport Security(ATS)๋ผ๊ณ ํ์ง๋ง,
์น๋ทฐ(WebView)๋ก ์ ์ํ๋ ค๋ ์น์ฌ์ดํธ๊ฐ HTTP(์ํธํ๋์ง ์์ ํต์ )๋ฅผ ์ฌ์ฉํ๊ฑฐ๋,
ํน์ ํ ์ด์ ๋ก ๋ชจ๋ ๋๋ฉ์ธ์ ๋ํด ์์ธ๋ฅผ ํ์ฉํด์ผ ํ ๋๊ฐ ์๋ค.
์์ ๊ฐ์ ์ํฉ์ด ์์ ์ ์์ด ์๋์ ๊ฐ์ด ์ค์ ํด์ค์ผ ํ๋ค.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
3. ์น๋ทฐ ์ฝ๋
ํธ์์ main์์ ์น๋ทฐ๋ฅผ ๊ตฌํํ๋ค.
๋ค๋ฅธ ํ๋ก์ ํธ์์๋ ์น๋ทฐ ์คํฌ๋ฆฐ๊ณผ ์คํ๋์ฌ ํ๋ฉด์ ๋ฐ๋ก ๋ง๋ค์ด์ ํ๋ค.
๊ทธ๋ฆฌ๊ณ ์๋ ์ฝ๋์์๋ debug ๋ฆฌ๋ณธ๋ ์์ ๊ณ
SafeArea๋ก ์ํ๋ฐ์ ๋
ธ์น์ ํ๋ฉด์ด ๊ฒน์ณ ๋ถํธํ ํ์๋ ์์ด๋ค.
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});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter WebView App',
// debug ๋ฆฌ๋ณธ ์์ ๊ธฐ
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'));
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
resizeToAvoidBottomInset: true,
// SafeArea๋ก ์ํ๋ฐ ๋
ธ์น ๊ฐ๋ฆฌ์ง ์๋๋ก
body: SafeArea(
child: WebViewWidget(controller: _controller),
),
);
}
}