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

auto_direction 封面
插件详情v0.0.7

auto_direction

此包根据提供的文本语言,将小部件的方向从从左到右(LTR)更改为从右到左(RTL),反之亦然。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1860
喜欢数
88
Pub 分数
40

安装插件

flutter pub add auto_direction

插件介绍

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

auto_direction 包可自动根据检测到的语言调整 Flutter 应用中控件的文本方向,实现从左到右(LTR)和从右到左(RTL)布局之间的切换。它通过动态适应 UI 方向而无需手动干预,简化了国际化,确保阿拉伯语、希伯来语等使用 RTL 脚本的语言能够正确渲染。该包可无缝集成到面向多语言受众的应用程序中。

适合场景

  • 动态UI布局适应
  • 多语言应用程序支持
  • RTL/LTR 文本方向切换
  • 国际化用户界面
  • 自动语言布局调整

主要特点

  • 基于语言的方向检测
  • 自动 LTR/RTL 切换
  • 与 Flutter 小部件的无缝集成
  • 对多平台的支持
  • 所需配置最少

适合对象

  • 面向全球受众的应用
  • 使用 Flutter 进行国际化开发的开发者
  • 需要动态文本方向的项目
  • 包含混合语言内容的 UI
  • 支持 RTL 语言的 Web 和移动应用

使用建议

  • 需要准确的语言检测
  • 可能需要额外的逻辑来处理复杂布局
  • 不适用于静态方向设计
  • 取决于正确的区域设置
  • 仅限文本方向更改,不支持完整从右到左主题

原始 README

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

auto_direction

This widget changes the direction of a widget from ltr direction into rtl direction and vice versa based on the language of the text provided.

Auto RTL on a TextField

Getting Started

This widget will wrap its child with a Directionality widget and it will decide the direction based on the provided text.

...
String text = "";
...
AutoDirection(
  text: text,
  child: TextField(
    onChanged: (str){
      setState(() {
        text = str;
      });
    },
  ),
)

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目