패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.7.4

web_browser

웹 브라우저 위젯입니다. webview_flutter와 달리 크로스 플랫폼 네비게이션 및 URL 공유 위젯을 포함하고 있습니다. Android, iOS, 브라우저 및 기타 플랫폼에서 작동합니다.

AndroidiOSmacOS
30일 다운로드
100
좋아요
71
Pub 점수
140

패키지 설치

flutter pub add web_browser

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

web_browser 패키지는 플러터용 크로스플랫폼 웹 브라우저 위젯을 제공하며, 내장된 탐색 컨트롤과 URL 공유 기능을 포함합니다. webview_flutter와 달리, 일관된 UI 구성 요소를 유지하면서 안드로이드, iOS, macOS 및 웹 플랫폼에서 원활하게 작동하도록 설계되었습니다. 플랫폼별 동작과 사용자 경험 기준을 유지하면서 웹 콘텐츠를 쉽게 삽입할 수 있습니다. 뒤로/앞으로 버튼과 공유 가능한 URL과 같은 직관적인 탐색 도구를 포함하여, 일반적인 브라우저 기능을 다시 만들지 않고도 통합된 브라우징 기능이 필요한 앱에 이상적입니다.

사용 사례

  • 모바일 및 데스크톱 앱에 웹 콘텐츠 삽입
  • 네비게이션을 갖춘 앱 기반 브라우저 구축
  • 앱 내에서 URL 공유하기
  • 하이브리드 웹 네이티브 애플리케이션 만들기
  • 다양한 플랫폼에서 앱 내 브라우징 활성화

주요 기능

  • 크로스 플랫폼 호환성 (Android, iOS, macOS, 웹)
  • 내장형 탐색 컨트롤
  • URL 공유 통합
  • 플랫폼 간 일관된 사용자 인터페이스
  • 경량이며 통합이 쉬움

적합한 대상

  • 웹 콘텐츠를 사용하여 다중 플랫폼 앱을 개발하는 개발자
  • 간단한 브라우저 기능이 필요한 앱
  • 임베디드 웹 뷰에서 URL 공유가 필요한 프로젝트
  • 사용자 정의 WebView 구현을 피하고 싶은 팀
  • 네이티브처럼 브라우징을 원하는 하이브리드 앱 개발자

고려 사항

  • 원시 WebView에 비해 사용자 지정이 제한적
  • 플랫폼별 렌더링 동작에 의존합니다
  • 일부 플랫폼에서는 추가 권한이 필요할 수 있습니다
  • 복잡한 웹 앱 호스팅에 적합하지 않음
  • 오래된 기기에서는 성능이 다를 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Pub Package Github Actions CI

Overview

The package gives you Browser, a Flutter widget for displaying web pages.

The package is built on top of webview_flutter and it adds navigation widgets that:

  • Display the domain.
  • Allow user to tap "back", "forward", "refresh", or share the URL using a native dialog of each platform.
  • Display website loading error messages in a visually pleasant and easy-to-understand way.

Browser has been tested in Android, iOS, and browsers. By adding relevant "webview_flutter" plugin dependencies to your "pubspec.yaml", you can use this package in Windows, Mac OS X, and Linux too.

Licensed under the Apache License 2.0.

Links

Setting up

1.Setup

In pubspec.yaml:

dependencies:
  web_browser: ^0.7.4

2.Display web browser

import 'package:flutter/material.dart';
import 'package:web_browser/web_browser.dart';

void main() {
  runApp(const MaterialApp(
    home: Scaffold(
      body: SafeArea(
        child: Browser(
          initialUriString: 'https://flutter.dev/',
        ),
      ),
    ),
  ));
}

Manual

Default designs

The package contains two designs, Cupertino (web_browser.cupertino) and Material (web_browser.material). By default, the package chooses a Cupertino or Material design based on whether the app is CupertinoApp or MaterialApp. You can override the defaults by using relevant parameters of Browser() constructor.

The Cupertino and Material navigation bars look like this:

Localization

Use BrowserLocalizations to localize the widgets.

void main() {
  runApp(MaterialApp(
    localizations: [
      ...browserLocalizationsList,
      // ...
    ],
    // ...
  ));
}

final browserLocalizationsList = [
  // Spanish localization
  BrowserLocalizations.forLocale(
    locale: Locale('es'),
    load: (locale) async => BrowserLocalizations(
      couldNotReach: 'No se pudo acceder al sitio web.',
      // ...
    ),
  ),
];

Setting various parameters

You can give various parameters to Browser:

import 'package:flutter/material.dart';
import 'package:web_browser/web_browser.dart';

void main() {
  runApp(const MaterialApp(
    home: Scaffold(
      body: SafeArea(
        child: Browser(
          initialUriString: 'https://flutter.dev/',
          controller: BrowserController(
            // "User-Agent" HTTP header.
            userAgent: 'Your user agent',
            
            // Can user zoom into the content? Default is true.
            isZoomingEnabled: false,
          )
        ),
      ),
    ),
  ));
}

Cache clearing

For end-users privacy, it is good to clear:

  • Cookies
  • Caches
  • Local storage

You can enable this by setting:

import 'package:web_browser/web_browser.dart';

void main() {
  // Clear when the app is started
  BrowserController.resetGlobalStateAtStart = true;
  
  // Clear every now and then.
  BrowserController.globalStateExpiration = const Duration(days: 1);
  
  // ...
}

Accessing WebViewController

To access WebViewController by using browserController.webViewController.

카테고리

의존성

의존성 목록 6 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.