easy_sinhala_text 0.0.1
easy_sinhala_text: ^0.0.1 copied to clipboard
A Flutter package for easy Sinhala text rendering with multiple font options
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:easy_sinhala_text/easy_sinhala_text.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sinhala Text Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sinhala Text Example'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title
const Text(
'Sinhala Text Examples',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 20),
// Example 1: Basic usage with Iskoola Pota
_buildExampleSection(
'Example 1: Basic Usage (Iskoola Pota)',
SinhalaText(
'ආයුබෝවන්',
font: SinhalaFont.iskoolaPota,
style: const TextStyle(fontSize: 24),
),
),
// Example 2: FM Abhaya with custom style
_buildExampleSection(
'Example 2: Custom Style (FM Abhaya)',
SinhalaText(
'ආයුබෝවන්',
font: SinhalaFont.fmAbhaya,
style: const TextStyle(
fontSize: 24,
color: Colors.blue,
fontWeight: FontWeight.bold,
),
),
),
// Example 3: Noto Sans Sinhala with paragraph
_buildExampleSection(
'Example 3: Paragraph (Noto Sans Sinhala)',
SinhalaText(
'ආයුබෝවන්, මම ඔබට සුභ පැතුම් යොමු කරමි. මෙය සිංහල භාෂාවෙන් ලියන ලද පාඨයකි.',
font: SinhalaFont.notoSansSinhala,
style: const TextStyle(fontSize: 18),
),
),
// Example 4: Bhashitha Unicode with different sizes
_buildExampleSection(
'Example 4: Different Sizes (Bhashitha Unicode)',
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SinhalaText(
'ආයුබෝවන්',
font: SinhalaFont.bhashithaUnicode,
style: const TextStyle(fontSize: 32),
),
const SizedBox(height: 8),
SinhalaText(
'ආයුබෝවන්',
font: SinhalaFont.bhashithaUnicode,
style: const TextStyle(fontSize: 24),
),
const SizedBox(height: 8),
SinhalaText(
'ආයුබෝවන්',
font: SinhalaFont.bhashithaUnicode,
style: const TextStyle(fontSize: 18),
),
],
),
),
// Example 5: Mixed content
_buildExampleSection(
'Example 5: Mixed Content',
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SinhalaText(
'ආයුබෝවන්',
font: SinhalaFont.iskoolaPota,
style: const TextStyle(fontSize: 24),
),
const SizedBox(height: 8),
SinhalaText(
'මෙය සිංහල භාෂාවෙන් ලියන ලද පාඨයකි.',
font: SinhalaFont.fmAbhaya,
style: const TextStyle(fontSize: 18),
),
],
),
),
],
),
),
);
}
Widget _buildExampleSection(String title, Widget content) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 24),
Text(
title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.grey,
),
),
const SizedBox(height: 8),
content,
],
);
}
}