搜尋套件、儲存庫與 APP 分類

套件詳情v0.3.0

url_strategy

Flutter 套件,可透過一行程式碼設定網頁應用的 URL 策略。

AndroidiOSLinuxmacOSWebWindows
近 30 天下載
10.8萬
喜歡數
554
Pub 分數
160

安裝套件

flutter pub add url_strategy

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

url_strategy 套件透過單一行程式碼設定 URL 策略,讓 Flutter Web 應用程式能使用乾淨、易讀的 URL。它允許開發者在基於雜湊的路由(例如 /#/home)與基於路徑的路由(例如 /home)之間切換,進而提升搜尋引擎優化與使用者體驗。此套件輕量且專為 Flutter Web 設計,確保無需額外設定即可順暢整合。支援所有主要平台,包含 Web、Android、iOS、Linux、macOS 與 Windows。

適用情境

  • 在 Flutter Web 應用中啟用乾淨的 URL
  • 改善基於Web的Flutter應用程式之SEO
  • 簡化僅限 Web 的 Flutter 專案中的導航
  • 支援 Web 應用中的深度連結
  • 跨平台維持路由一致性

主要特色

  • 單行URL策略設定
  • 支援雜湊與路徑兩種路由方式
  • 輕量級且開銷極小
  • 跨平台相容性
  • 輕鬆整合至現有的 Flutter Web 項目

適合對象

  • Flutter 開發者建構 Web 應用
  • 需要SEO友好的URL的專案
  • 使用深度連結或共用連結的應用
  • 重視清晰URL結構的團隊
  • 針對 Web 部署的開發人員

使用建議

  • 僅適用於Web部署
  • 需要正確的伺服器設定以支援基於路徑的路由
  • 僅適用於移動端的 Flutter 應用不需要此功能
  • 可能需要為生產環境託管調整後端
  • 在 Web 環境之外的用途有限

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

url_strategy Pub version

⚠️ Discontinued: The functionality is now provided by the flutter SDK out of the box:

https://docs.flutter.dev/ui/navigation/url-strategies

Package for Flutter apps that allows setting the web URL strategy with a single line of code.

Usage

With a simple call of setPathUrlStrategy, your Flutter web app does not have a leading # in the URL anymore 🚀

import 'package:url_strategy/url_strategy.dart';

void main() {
  // Here we set the URL strategy for our web app.
  // It is safe to call this function when running on mobile or desktop as well.
  setPathUrlStrategy();
  runApp(MyApp());
}

See the url_strategy package README or the explanation on StackOverflow for more detailed usage documentation.

Implementation

The package is basically a wrapper around the flutter_web_plugins setUrlStrategy. The reason it exists is that using the function from flutter_web_plugins requires conditional imports.
The problem is solved by using a conditional export from the url_strategy package.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。