easily_rich_text 0.0.2 copy "easily_rich_text: ^0.0.2" to clipboard
easily_rich_text: ^0.0.2 copied to clipboard

Rich text yazımını kolaylaştıran ve özelleştirilebilir desenler sunan Widget

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Easy Rich Text Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: EasyRichTextDemo(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Easy Rich Text Örnekleri')),
      body: SingleChildScrollView(
        padding: EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            _buildExample(
              'Basit Stil Uygulama',
              'Bu metin kalın, bu metin italik ve bu metin altı çizili.',
              [
                EasyPatterns.bold('kalın'),
                EasyPatterns.italic('italik'),
                EasyPatterns.underline('altı çizili'),
              ],
            ),
            SizedBox(height: 20),
            _buildExample(
              'Renk Uygulaması',
              'Kırmızı metin, mavi metin ve yeşil metin örnekleri.',
              [
                EasyPatterns.color('Kırmızı', Colors.red),
                EasyPatterns.color('mavi', Colors.blue),
                EasyPatterns.color('yeşil', Colors.green),
              ],
            ),
            SizedBox(height: 20),
            _buildExample(
              'Önceden Tanımlanmış Desenler',
              'E-posta: test@example.com\nWebsite: https://flutter.dev\nTelefon: +90 555 123 45 67\n#flutter #dart @google',
              [
                EasyPatterns.email(),
                EasyPatterns.url(),
                EasyPatterns.phone(),
                EasyPatterns.hashtag(),
                EasyPatterns.mention(),
              ],
            ),
            SizedBox(height: 20),
            _buildExample(
              'Tıklanabilir Metin',
              'Bu linke tıklayın ve bu butona basın.',
              [
                EasyPatterns.link('linke tıklayın', () {
                  _showDialog(context, 'Link tıklandı!');
                }),
                EasyTextPattern(
                  pattern: 'butona basın',
                  style: TextStyle(
                    color: Colors.purple,
                    fontWeight: FontWeight.bold,
                    decoration: TextDecoration.underline,
                  ),
                  onTap: () {
                    _showDialog(context, 'Buton tıklandı!');
                  },
                ),
              ],
            ),
            SizedBox(height: 20),
            _buildExample(
              'Regex Desenleri',
              'Tariher: 15/07/2023 ve 2023-07-15 formatında.',
              [
                EasyTextPattern(
                  pattern: r'\d{2}/\d{2}/\d{4}',
                  isRegex: true,
                  style: TextStyle(
                    color: Colors.orange,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                EasyTextPattern(
                  pattern: r'\d{4}-\d{2}-\d{2}',
                  isRegex: true,
                  style: TextStyle(
                    color: Colors.teal,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
            SizedBox(height: 20),
            _buildExample(
              'Karmaşık Metin',
              'Bugün #harika bir gün! @arkadaşım ile birlikte https://flutter.dev sitesini ziyaret ettik. İletişim: info@flutter.dev',
              [
                EasyPatterns.hashtag(),
                EasyPatterns.mention(),
                EasyPatterns.url(),
                EasyPatterns.email(),
              ],
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildExample(
    String title,
    String text,
    List<EasyTextPattern> patterns,
  ) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.bold,
            color: Colors.blue,
          ),
        ),
        SizedBox(height: 8),
        Container(
          padding: EdgeInsets.all(12),
          decoration: BoxDecoration(
            color: Colors.grey[100],
            borderRadius: BorderRadius.circular(8),
            border: Border.all(color: Colors.grey[300]!),
          ),
          child: EasyRichText(
            text,
            patternList: patterns,
            defaultStyle: TextStyle(fontSize: 16),
          ),
        ),
      ],
    );
  }

  void _showDialog(BuildContext context, String message) {
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        title: Text('Bilgi'),
        content: Text(message),
        actions: [
          TextButton(
            onPressed: () => Navigator.of(context).pop(),
            child: Text('Tamam'),
          ),
        ],
      ),
    );
  }
}
2
likes
135
points
24
downloads

Publisher

unverified uploader

Weekly Downloads

Rich text yazımını kolaylaştıran ve özelleştirilebilir desenler sunan Widget

Homepage

Topics

#flutter #rich-text #text-formatting #ui #widget

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on easily_rich_text