Building an Android App with WebView Using URLs

WebView is a powerful component in Android development that allows developers to embed web content directly into their applications. While initially loading a static URL is straightforward, there are scenarios where developers might need to dynamically change the website URL during runtime. In this blog post, we’ll explore how to achieve this functionality effectively.

Using WebView to Display Websites: WebView is commonly used in Android apps to display web content, such as websites, within the app’s user interface. Typically, developers initialize a WebView with a specific URL using the loadUrl() method.



Step 1:- Import Dependencies in main.dart

Step 2:- Import from

Step 3:- If the import dependencies file is not found in main.dart
Mouse Hover on the package and then click on Quick Fix-> Add’webview_flutter’ to dependencies

Step 4:- Write a code in main.dart

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});

  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'All In One',
      theme: ThemeData(
        primarySwatch: Colors.amber,
    home: const WebViewDemo(),

class WebViewDemo extends StatefulWidget {
  const WebViewDemo({super.key});

  State<WebViewDemo> createState() => _MyWidgetState();

class _MyWidgetState extends State<WebViewDemo> {
  WebViewController controller = WebViewController();
void initState(){
  ..setBackgroundColor(const Color(0x00000000))
     onProgress: (progress) => {},
     onPageStarted: (url) => {},
     onPageFinished: (url) => {},

  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: const Text('Tools')
body: WebViewWidget(controller: controller),

Output:- Refresh the Emulator

Hopefully, It will help you…!!

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x