Skip to content
pubscout

legalize

1.2.2, released 3 years ago by caesarovich.xyz

Provides functions to validate and sanitize filenames for various operating systems.

WASM-ready
$ flutter pub add legalize
Source repository

What it does

The package checks filenames against OS-specific restrictions and can remove or replace illegal characters. It offers both validation and sanitization helpers for Windows, macOS/iOS (HFS), Android (FAT), and POSIX systems.

AI-written summary of version 1.2.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to ensure filenames are safe before saving them on disk
  • You support multiple platforms and want a single API for filename rules

Skip it when

  • You require advanced filesystem features beyond basic character checks
  • You need real-time streaming validation of filenames

Strengths

  • Covers major OS filename rules in one library
  • Simple, zero‑dependency API
  • Allows custom control‑character handling

Weaknesses

  • Limited to character sanitization, no path handling
  • Package is still marked as in development

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:legalize/legalize.dart';

void main() {
  const someFilename = 'my?/?/?File.txt';
  final sanitized = legalizeFilename(someFilename);
  print(sanitized); // myFile.txt
}

Alternatives

Packages that do the same job and could replace legalize.