작성
·
451
·
수정됨
1
다른분도 비슷한 질문을 올리셨던데 임포트를 한번만 진행했는데도 뜹니다.
코드 전문을 올려보겠습니다. 한번 봐주시면 감사드리겠습니다!
//main.dart 부분
import 'package:flutter/material.dart';
import 'package:splash_page/screen/home_screen.dart';
void main() {
// Flutter 프레임워크가
// 앱을 실행할 준비가 될 때 까지 기다린다.
WidgetsFlutterBinding.ensureInitialized();
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: HomeScreen(),
),
);
}
//homescreen.dart 부분
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
final HomeURL = Uri.parse('https://blog.codefactory.ai');
class HomeScreen extends StatelessWidget {
WebViewController controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadRequest(HomeURL);
HomeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Code Factory!"),
centerTitle: true,
actions: [
IconButton(
onPressed: () {
// if(controller == null){
// return;
// }
controller!.loadRequest(HomeURL);
},
icon: Icon(Icons.home),
)
],
backgroundColor: Colors.orange,
),
body: WebViewWidget(
controller: controller,
),
// WebView(
// onWebViewCreated: (WebViewController controller) {
// this.controller = controller;
// },
// initialUrl: HomeURL,
// javascriptMode: JavascriptMode.unrestricted,
// )
);
}
}