smart_text_widget 0.0.2+5 copy "smart_text_widget: ^0.0.2+5" to clipboard
smart_text_widget: ^0.0.2+5 copied to clipboard

A smart text widget that handles null, list, map, and more.

example/main.dart

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

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'RTText Widget Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('RTText Widget Showcase'),
        ),
        body: const SingleChildScrollView(
          child: Padding(
            padding: EdgeInsets.all(12.0),
            child: RTTextShowcase(),
          ),
        ),
      ),
    );
  }
}

class RTTextShowcase extends StatelessWidget {
  const RTTextShowcase({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        const Text(
          'ResearchThinker Smart Text Widget: Handles Null, Empty, List, and Map values.',
          style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: 10),
        // Null Value Example
        const RTText(
          text: null,
          errorTrue: true,
          errorValue: "Null Value Encountered!",
          truncateEnable: true,
          truncateSize: 10,
          customEllipsis: "-->",
          maxWidth: true,
        ),
        const SizedBox(height: 10),
        const RTText(  // Empty String Example
          text: "",
          errorTrue: true,
          errorValue: "Empty String!",
          maxWidth: true,
        ),
        const SizedBox(height: 10),
        const RTText( // Zero Value Example
          text: "0.0",
          truncateEnable: true,
          truncateSize: 4,
          textAlign: TextAlign.center,
          maxWidth: true,
          customEllipsis: " ==> ",
        ),
        const SizedBox(height: 10),
        const RTText( // List Example with Separator
          text: ["Apple", "Banana", "Cherry"],
          scroll: true,
          listSeparator: " | ",
          textAlign: TextAlign.center,
          textStyle: TextStyle(fontSize: 16, color: Colors.blue, fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: 10),
        const RTText(
          text: ["Apple", "Banana", "Cherry"],
          scroll: true,
          listSeparator: " , ",
          textAlign: TextAlign.center,
          textStyle: TextStyle(fontSize: 16, color: Colors.blue, fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: 10),
        const RTText(
          text: ["Apple", "Banana", "Cherry"],
          scroll: true,
          listSeparator: " - ",
          textAlign: TextAlign.center,
          textStyle: TextStyle(fontSize: 16, color: Colors.blue, fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: 10),
        const RTText( // Map Example
          text: {"name": "ResearchThinker", "website": "https://researchthinker.com"},
          errorTrue: false,
          maxWidth: true,
          emptyPlaceholder: "No data available",
          textAlign: TextAlign.right,
        ),
        const SizedBox(height: 10),
        const RTText(  // Dynamic Value Example
          text: 120,
          textStyle: TextStyle(color: Colors.green, fontSize: 18),
          textAlign: TextAlign.left,
          maxWidth: true,
        ),
        const SizedBox(height: 10),
        const RTText(  // Large String with Scroll and Max Width
          text: "This is a very long text that might not fit in a single line and needs to be scrolled or truncated.",
          scroll: true,
          maxWidth: true,
          truncateSize: 62,
          truncateEnable: true,
          textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
          textAlign: TextAlign.justify,
        ),
      ],
    );
  }
}
1
likes
0
pub points
27%
popularity

Publisher

unverified uploader

A smart text widget that handles null, list, map, and more.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on smart_text_widget