搜索插件、代码仓与 APP 分类

meta_seo 封面
插件详情v3.0.9

meta_seo

Meta SEO 是一个用于在 head 标签中添加 HTML 文档元数据的包,元标签或元数据可为 Web 应用提供搜索引擎优化。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
4960
喜欢数
183
Pub 分数
150

安装插件

flutter pub add meta_seo

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Meta SEO 是一个专为 Web 应用程序设计的 Flutter 包,用于动态管理文档头部的 HTML 元标签。它使开发者能够通过设置标题、描述、关键词和 Open Graph 属性等元数据来增强搜索引擎优化(SEO)。该包可无缝集成到 Flutter Web 项目中,无需手动操作 DOM 即可轻松自定义 SEO 元素。它支持所有主要平台,包括 Web、Android、iOS、macOS、Windows 和 Linux,非常适合需要强大 SEO 性能的跨平台 Web 应用。

适合场景

  • 提高搜索引擎可见性
  • 增强社交媒体分享
  • 优化网页应用元数据
  • 多页应用的动态SEO
  • 支持网页分析跟踪

主要特点

  • 与 Flutter Web 的轻松集成
  • 动态元标签管理
  • 支持 Open Graph 和 Twitter 卡片
  • 跨平台兼容性
  • 自动更新标题标签

适合对象

  • Flutter web 开发人员
  • 面向搜索引擎优化的Web应用
  • 动态内容的应用程序
  • 以营销为导向的网页应用
  • 全栈 Flutter 团队

使用建议

  • 主要针对Web平台
  • 需要手动处理服务器端渲染
  • 仅限客户端元数据管理
  • 不适用于非 Web 目标
  • 依赖于在Flutter的Web构建过程中的正确使用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

MetaSEO Package

Pub Star on Github License: MIT


Meta Seo

Flutter package for Meta SEO.

Screenshots

Screen Shot 2022-10-08 at 12 01 33 PM

About:

  • Meta SEO is package for adding meta data for html document in head tag which meta tags or meta data make search engine optimization for web apps.

Installation and Basic Usage

First: Add to pubspec.yaml:

dependencies:
  meta_seo: ^3.0.9

Second: import it to your project:

import 'package:meta_seo/meta_seo.dart';
import 'package:flutter/foundation.dart';

Then add the config MetaSEO method before the running of the Flutter app into main.dart file:

void main() {
  // It is required to add the following to run the meta_seo package correctly
  // before the running of the Flutter app
  if (kIsWeb) {
    MetaSEO().config();
  }
  runApp(const MyApp());
}

Finally add MetaSEO into your target web pages:

@override
Widget build(BuildContext context) {

  // Add MetaSEO just into Web platform condition
  if(kIsWeb) {
    // Define MetaSEO object
    MetaSEO meta = MetaSEO();
    // add meta seo data for web app as you want
    meta.author(author: 'Eng Mouaz M AlShahmeh');
    meta.description(description: 'Meta SEO Web Example');
    meta.keywords(keywords: 'Flutter, Dart, SEO, Meta, Web');
  }

  return const Scaffold(
    body: Center(child: Text('Meta SEO Web Example')),
  );
}

Other example with GoRouter package

First: Add to pubspec.yaml:

dependencies:
  meta_seo: ^3.0.9
  go_router: ^5.2.0 # Add the latest version

Second: The same as before and add the config MetaSEO method before the running of the Flutter app into main.dart file:

void main() {
  // It is required to add the following to run the meta_seo package correctly
  // before the running of the Flutter app
  if (kIsWeb) {
    MetaSEO().config();
  }
  runApp(const MyApp());
}

Then follow GoRouter configuration steps and latest add MetaSEO into your GoRouter as you want:

final router = GoRouter(
  initialLocation: '/',
  routes: <GoRoute>[
    GoRoute(
      path: '/',
      builder: (BuildContext context, GoRouterState state) {
        // Add MetaSEO just into Web platform condition
        if(kIsWeb) {
          // Define MetaSEO object
          MetaSEO meta = MetaSEO();
          // add meta seo data for web app as you want
          meta.ogTitle(ogTitle: 'First Screen');
          meta.description(description: 'First Screen');
          meta.keywords(keywords: 'Flutter, Dart, SEO, Meta, Web');
        }

        return const FirstScreen();
      },
    ),
    GoRoute(
      path: '/second_screen',
      builder: (BuildContext context, GoRouterState state) {
        // Add MetaSEO just into Web platform condition
        if(kIsWeb) {
          // Define MetaSEO object
          MetaSEO meta = MetaSEO();
          // add meta seo data for web app as you want
          meta.ogTitle(ogTitle: 'Second Screen');
          meta.description(description: 'Second Screen');
          meta.keywords(keywords: 'Flutter, Dart, SEO, Meta, Web');
        }

        return const SecondScreen();
      },
    ),
  ],
);

Extended MetaSEO tags

If you want to use Open Graph or Twitter Card meta tags

Note: You must be in live server not as a local host.

Note: The package delete any duplicated meta tags and keep the latest in order.

The same as before and if you want to use any tags does not exist into the main package methods just add extended tags as the below:

@override
Widget build(BuildContext context) {
  
    // Add MetaSEO just into Web platform condition
    if(kIsWeb) {
      // Define MetaSEO object
      MetaSEO meta = MetaSEO();
      // add meta seo open graph tags as you want
      meta.facebookAppID(facebookAppID: 'your_app_id');
      meta.ogTitle(ogTitle: 'Example Screen');
      meta.ogDescription(ogDescription: 'Example Screen Description');
      meta.ogImage(ogImage: 'https://example.com/example.png');

      // here you can add any tags does not exist in the package as this
      meta.propertyContent(property: 'og:site_name', content: 'example');
      
      // or if you want to add twitter card meta tags just as the following
      meta.twitterCard(twitterCard: TwitterCard.summaryLargeImage);
      meta.twitterTitle(twitterTitle: 'Example Screen');
      meta.twitterDescription(twitterDescription: 'Example Screen Description');
      meta.twitterImage(twitterImage: 'https://example.com/example.png');
    
      // here you can add any tags does not exist in the package as this
      meta.nameContent(name: 'twitter:site', content: '@mouaz_m_shahmeh');
    }
    
    return const Scaffold(
      body: Center(child: Text('Extended Meta SEO Web Example')),
    );
}

Make sure to check out go_router_meta_seo_example project. If you find this package useful, star my example GitHub repository.

Thank you

Make sure to check out example project. If you find this package useful, star my GitHub repository.

Flutter plugin was developed by: Eng Mouaz M. Al-Shahmeh

所属分类

源码仓库

使用此插件的项目

暂无相关数据。