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

action_process_text 封面
插件详情v0.0.6

action_process_text

一个用于在 Android 上实现 ACTION_PROCESS_TEXT 的 Flutter 插件。

近 30 天下载
115
喜欢数
31
Pub 分数
40

安装插件

flutter pub add action_process_text

插件介绍

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

一个 Flutter 插件,可在 Android 上启用 ACTION_PROCESS_TEXT 功能,使应用程序能够与系统的文本处理操作集成。它支持在选择文本时触发自定义应用行为,例如分享、翻译或直接从 Android 文本选择菜单分析内容。该插件将原生 Android 功能与 Flutter 应用连接起来,通过上下文相关的文本操作增强用户交互体验。此插件专为 Android 设计,除了标准 Flutter 设置外无需额外配置。

适合场景

  • 在 Android 中集成自定义文本操作
  • 启用上下文感知的文本处理
  • 扩展 Android 的文本选择菜单
  • 支持文本分析工作流程
  • 通过文本选择添加分享或翻译选项

主要特点

  • Android 特定的 ACTION_PROCESS_TEXT 支持
  • 与 Flutter 的无缝集成
  • 上下文文本操作触发
  • 所需设置最少
  • 原生 Android 行为模拟

适合对象

  • 面向 Android 的 Flutter 应用
  • 文本处理扩展
  • 需要深度 Android 集成的应用程序
  • 面向 Android 文本操作的开发者
  • 可定制的文本交互功能

使用建议

  • 仅限 Android 平台
  • 需要 Android SDK 知识
  • 不支持 iOS
  • 依赖于 Android 系统行为
  • 可能需要在不同版本的 Android 上进行测试

原始 README

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

ACTION_PROCESS_TEXT Flutter

A flutter plugin for ACTION_PROCESS_TEXT implementation in android.

What is it used for?

It can be used when you want your users to use a shortcut for opening your app when selecting text anywhere in the android environment.

Constraints

1. It works only for android.
2. It can only be used inside a Stateful widget.
3. Use setState() after updating the value from the action.

Include in your project

dependencies:
  action_process_text: <latest version>

Run pub get and get packages.

Add this to AndroidManifest.xml in the android\app\src\main\ folder.

  <activity android:name="com.example.action_process_text.ActionProcessTextPlugin"
            android:label="Action_Text" android:theme="@style/LaunchTheme">
            <intent-filter>
                <action android:name="android.intent.action.PROCESS_TEXT" />
                <data android:mimeType="text/plain"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
   </activity>

Change the android:label from Action_Text to the action text that you want to display.

Then import the package to use it.

import 'package:action_process_text/action_process_text.dart';

Usage

Use the constructor of the widget to initialize the action_process_text. ActionProcessText.getInputText is used to get the selected text from the android action.

class MainPage extends StatefulWidget {
  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  _MainPageState() {
    initActionProcessText();
  }

  Future<void> initActionProcessText() async {
    inputText = await ActionProcessText.getInputText;
    setState(() {});
  }

  String inputText = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold();
  }
  }

If you want to check whether the call was made from the native side, you can use the ActionProcessText.calledFromNative . This enables one to navigate to a different screen than usual if needed, by initiating the channel at the start and check if the value is true. If true, the input text will be available. When it's false, the app is opened not by the action_process_text intend, but by the user as in usual cases.

Bugs/Requests

If you encounter any problems feel free to open an issue. Pull request are also welcome.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。