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

套件詳情v1.3.0

message_segment_calculator

高效計算支援 GSM 與 UCS-2 編碼的簡訊段數。適用於需要精確管理簡訊長度與成本的應用程式。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
299
喜歡數
8
Pub 分數
160

安裝套件

flutter pub add message_segment_calculator

套件介紹

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

message_segment_calculator 套件能有效判斷給定訊息所需的簡訊區段數,支援 GSM 與 UCS-2 字元編碼。它可精確控制訊息長度,並透過準確計算訊息將佔用的區段數,協助管理簡訊成本。適用於需要高傳遞效率與成本控制的簡訊通知、警示或行銷訊息應用程式。此套件輕量且跨平台相容,支援 Android、iOS、Web、macOS、Windows 與 Linux。

適用情境

  • 簡訊費用估算
  • 訊息長度驗證
  • 批量簡訊管理
  • 通知系統
  • 遵守簡訊限制
  • 跨平台簡訊應用

主要特色

  • 支援 GSM 和 UCS-2 編碼
  • 準確的分段計數
  • 跨平台相容性
  • 輕便且快速
  • 即時長度計算
  • 正確處理特殊字元

適合對象

  • 訊息應用
  • 電信工具
  • 行銷平台
  • 企業通知系統
  • 需要簡訊費用控制的應用

使用建議

  • 需要手動處理長訊息
  • 不發送訊息——僅計算區段
  • 編碼選擇必須根據內容來確定
  • 不適用於MMS或多媒體訊息
  • 僅限簡訊特定使用案例

原始 README

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

SMS Segment Calculator

The SMS Segment Calculator is a Dart package designed to help developers accurately calculate the number of SMS segments required for messages. It supports both GSM-7 and UCS-2 encoding standards, providing a robust solution for applications that involve SMS messaging. The package ensures cost-effective messaging by optimizing message segmentation and encoding.

Key Features

  • Accurate SMS Segmentation: Automatically calculates the number of segments needed for a given SMS message based on its content and required encoding (GSM-7 or UCS-2).
  • Support for Special Characters and Emojis: Detects texts containing emojis or special characters and switches to UCS-2 encoding when necessary.
  • Comprehensive Encoding Management: Handles the encoding of individual characters and manages their conversion to the appropriate encoding format.
  • Cost Management: Provides precise segment counts for budgeting and planning SMS costs effectively.
  • Line Break Handling: Identifies different line break styles and issues warnings if incompatible styles are detected.

Installation

To integrate the SMS Segment Calculator into your Dart or Flutter project, add the following dependency to your pubspec.yaml file:

dependencies:
  message_segment_calculator: ^1.1.0



## Usage

import 'package:flutter/material.dart';
import 'package:message_segment_calculator/src/segmented_message.dart';

void main() {
  runApp(const App());
}

/// The root widget of the application.
class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MessageSegmentCalculatorWidget(),
    );
  }
}

/// A stateful widget that provides a UI for calculating message segments.
class MessageSegmentCalculatorWidget extends StatefulWidget {
  const MessageSegmentCalculatorWidget({super.key});

  @override
  State<MessageSegmentCalculatorWidget> createState() =>
      _MessageSegmentCalculatorWidgetState();
}

/// The state class for [MessageSegmentCalculatorWidget].
class _MessageSegmentCalculatorWidgetState
    extends State<MessageSegmentCalculatorWidget> {
  final textEditingController = TextEditingController();
  SegmentedMessage? segmentedMessage;

  @override
  void dispose() {
    textEditingController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Message Segment Calculator'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(10),
        child: Column(
          children: [
            const Text('Enter text'),
            const SizedBox(height: 10),
            TextFormField(
              decoration: const InputDecoration(),
              controller: textEditingController,
              onChanged: (value) {
                setState(() {
                  segmentedMessage = SegmentedMessage(value);
                });
              },
            ),
            const SizedBox(height: 10),
            Text('Number of characters: ${segmentedMessage?.numberOfCharacters}'),
            Text('Number of segments: ${segmentedMessage?.segmentsCount}'),
            Text('Number of Unicode scalars: ${segmentedMessage?.numberOfUnicodeScalars}'),
            Text('Message size in bits: ${segmentedMessage?.messageSize}'),
            Text('Total size in bits: ${segmentedMessage?.totalSize}'),
          ],
        ),
      ),
    );
  }
}




### Key Additions:
- **Detailed Descriptions**: Each class is explained to clarify its role in the package.
- **Usage Example**: Shows a practical example to help developers quickly understand how to use the package.
- **Installation Instructions**: Guides users on how to add the package to their project.
- **Contribution Guidelines**: Encourages contributions and provides a link to the issues page.

This README provides a comprehensive overview, making it easier for users to understand and use the package effectively.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。