Flutter WebViewの背景色を設定する方法
環境
Windows11 pro 64bit
Flutter 3.3.7
構文
WebViewの背景色を設定するには、引数「backgroundColor」を使います。
形式
WebView( initialUrl: 'url', backgroundColor: 背景色, ),
引数「backgroundColor」に背景色を指定します。
使用例
class _CftHomePageState extends State<MyHomePage> { var _isLoading = false; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('WebView Test'), ), body: Stack( children: [ WebView( backgroundColor: Colors.blue[100], initialUrl: 'https://www.xxxx.com', onPageStarted: (url) { setState(() { _isLoading = true; }); }, onPageFinished: (url) { setState(() { _isLoading = false; }); }, javascriptMode: JavascriptMode.unrestricted, ), if (_isLoading) Align( alignment: Alignment.center, child: CircularProgressIndicator(), ), ], ), ); } }