message_segment_calculator 1.2.0
message_segment_calculator: ^1.2.0 copied to clipboard
Efficiently calculate SMS segments for messages with support for GSM and UCS-2 encoding. Ideal for apps that require precise SMS length and cost management.
1.2.0 #
Added #
remainingCharsInSegmentproperty — Returns how many characters can still be added to the current (last) segment before a new segment is created. Useful for building real-time character counters and SMS cost previews.maxCharsPerSegmentproperty — Returns the maximum number of characters that fit in a single segment for the current encoding. Accounts for the User Data Header overhead in multi-segment messages (GSM-7: 160→153, UCS-2: 70→67).- 8 new unit tests — Comprehensive tests covering empty messages, exact boundary, single/multi-segment transitions, and extended GSM-7 characters for both new properties.
1.1.2 #
Fixed #
- CI/CD: skip example directory during publish — The
example/folder is a Flutter project which causeddart pub getto fail with exit code 69. CI now uses--no-examplefor dependency resolution and scopes format/analyze tolib/andtest/only.
1.1.1 #
Fixed #
- Replaced
flutter_lintswithlints— Theflutter_lintsdev dependency pulled in the Flutter SDK, causingdart pub publishto fail on CI with exit code 69. Replaced with the pure Dartlintspackage.
1.1.0 #
Breaking Changes #
- Converted to a pure Dart package — Removed Flutter SDK dependency (
flutter,flutter_test), making the package usable in any Dart project (CLI, server-side, Flutter, etc.). - Renamed
SmsEncodingenum toSmsEncodingMode— The previousSmsEncodingenum (withgsm7,ucs2,auto) is nowSmsEncodingMode. A newSmsEncodingenum (withgsm7,ucs2only) represents the resolved encoding. - Removed
ValidEncodingValuesenum — Replaced by the newSmsEncodingenum. - Replaced string-based encoding with enums —
EncodedCharnow usesSmsEncodingenum instead of raw strings like'gsm7'/'ucs2'.
Added #
- Introduced
SegmentElementsealed class — A new base type forEncodedCharandUserDataHeader, enabling type-safe segment composition and proper polymorphism. - Added new test cases — Tests for long GSM-7 multi-segment messages and long UCS-2 multi-segment messages.
- Added
toString()override onSegment— Useful for debugging segment details. - Added
repository,issue_tracker, andtopicsmetadata topubspec.yamlfor better pub.dev discoverability.
Changed #
- Replaced
grapheme_splitterdependency withcharacters— Uses the official Dartcharacterspackage for grapheme splitting, reducing dependency bloat. - Replaced
flutter_testwithtestpackage — Tests now use the standard Darttestpackage. - Type-safe segment elements —
Segment._elementschanged fromList<dynamic>toList<SegmentElement>,add()andremoveLast()now useSegmentElementtype. - Simplified line break processing — Grapheme line break handling now uses
expand()instead offold(). - Simplified
_hasAnyUCSCharacters— Refactored from a verbose loop to a conciseany()expression. - Improved
sizeInBits()calculations —Segment.sizeInBits()now correctly sums all element sizes (previously ignoredUserDataHeadersizes in computation). - Fixed
addHeader()bug —hasUserDataHeaderis now correctly set totrue(was previously set tofalseby mistake). - Fixed typo in filename — Renamed
enchoded_char.darttoencoded_char.dart. - Code cleanup — Replaced
var/explicit types withfinalwhere appropriate, used expression body syntax, and improved formatting throughout.
Removed #
- Removed
grapheme_splitterdependency — Replaced by thecharacterspackage. - Removed Flutter SDK dependency — Package is now pure Dart.
1.0.9 #
Changed #
- fix : removed unused functions
- fix : removed unused variables
- fix : removed unused imports
- fix : Code format and refractor
1.0.8 #
Changed #
- fix : segment calculation logics
- improved usability
- fix : encoding logic
- Updated the README with detailed descriptions and usage examples.
0.0.7 #
Added #
- Added the
SegmentedMessageclass to handle the segmentation logic for dividing a message into multiple SMS segments. - Added the
EncodedCharclass to represent individual characters and their encoding properties. - Added the
Segmentclass to manage individual segments, handle additions and removals, and calculate segment sizes. - Added the
UserDataHeaderclass to represent the User Data Header required for concatenated SMS messages. - Enabled
public_member_api_docslint to ensure all public API members are documented. - Introduced example usage in README for easy integration.
Changed #
- Improved error handling in the main entry point for better debugging and usability.
- Updated the README with detailed descriptions and usage examples.
0.0.1 #
- TODO: Describe initial release.