turkish_validators 0.0.3 copy "turkish_validators: ^0.0.3" to clipboard
turkish_validators: ^0.0.3 copied to clipboard

A Flutter package for Turkish-specific validation and formatting. Includes TC Kimlik No, IBAN, phone number, and Turkish Lira formatting.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:turkish_validators/turkish_validators.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'turkish_validators Example',
      theme: ThemeData(colorSchemeSeed: Colors.blue),
      home: const ExamplePage(),
    );
  }
}

class ExamplePage extends StatefulWidget {
  const ExamplePage({super.key});

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  final _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('turkish_validators Example')),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Form(
          key: _formKey,
          child: ListView(
            children: [
              // TC Kimlik
              TextFormField(
                decoration: const InputDecoration(
                  labelText: 'TC Kimlik No',
                  border: OutlineInputBorder(),
                ),
                validator: TcKimlik.formValidator,
                keyboardType: TextInputType.number,
                maxLength: 11,
              ),
              const SizedBox(height: 16),

              // IBAN
              TextFormField(
                decoration: const InputDecoration(
                  labelText: 'IBAN',
                  hintText: 'TR00 0000 0000 0000 0000 0000 00',
                  border: OutlineInputBorder(),
                ),
                validator: TurkishIban.formValidator,
                onChanged: (value) {
                  // Otomatik formatlama
                  final formatted = TurkishIban.format(value);
                  debugPrint(formatted);
                },
              ),
              const SizedBox(height: 16),

              // Telefon
              TextFormField(
                decoration: const InputDecoration(
                  labelText: 'Telefon',
                  hintText: '05XX XXX XX XX',
                  border: OutlineInputBorder(),
                ),
                validator: TurkishPhone.formValidator,
                keyboardType: TextInputType.phone,
              ),
              const SizedBox(height: 24),

              // TL Formatlama Örneği
              Card(
                child: Padding(
                  padding: const EdgeInsets.all(16),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text('TL Formatlama Örnekleri',
                          style: TextStyle(fontWeight: FontWeight.bold)),
                      const SizedBox(height: 8),
                      Text(TurkishLira.format(1250.5)),
                      Text(TurkishLira.format(99999.99)),
                      Text(TurkishLira.format(0.5)),
                    ],
                  ),
                ),
              ),
              const SizedBox(height: 24),

              ElevatedButton(
                onPressed: () {
                  if (_formKey.currentState!.validate()) {
                    ScaffoldMessenger.of(context).showSnackBar(
                      const SnackBar(content: Text('Tüm alanlar geçerli!')),
                    );
                  }
                },
                child: const Text('Doğrula'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
160
points
64
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package for Turkish-specific validation and formatting. Includes TC Kimlik No, IBAN, phone number, and Turkish Lira formatting.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on turkish_validators