text_wrap_auto_size 1.1.6 copy "text_wrap_auto_size: ^1.1.6" to clipboard
text_wrap_auto_size: ^1.1.6 copied to clipboard

Wraps text and auto sizes it dynamically with respect to the given dimensions.

example/example.dart

import 'package:flutter/material.dart';
import 'package:text_wrap_auto_size/text_wrap_auto_size_hyphend.dart';

class ExampleHyphenation extends StatefulWidget {
  final TextEditingController controller = TextEditingController(
      text:
          'The arts are a vast subdivision of culture, composed of many creative endeavors and disciplines.');

  ExampleHyphenation({super.key});

  @override
  State<ExampleHyphenation> createState() => _ExampleHyphenationState();
}

class _ExampleHyphenationState extends State<ExampleHyphenation> {
  String text = '';

  @override
  void initState() {
    super.initState();
    text = widget.controller.text;
    widget.controller.addListener(
      () => setState(() {
        // if (widget.controller.text != text) {
        text = widget.controller.text;
        // }
      }),
    );
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
      body: SingleChildScrollView(
          child: Column(
        children: [
          SizedBox(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height * 0.1,
              child: TextFormField(
                controller: widget.controller,
                decoration: const InputDecoration(hintText: 'Enter some text'),
                autofocus: true,
              )),
          const SizedBox(height: 16),
          SizedBox(
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height * 0.9,
            child: TextWrapAutoSizeHyphend(
              Text(
                text,
                style: const TextStyle(
                    color: Colors.red, fontWeight: FontWeight.bold),
                textAlign: TextAlign.right,
                key: ValueKey(text),
              ),
              'en_us',
              doShowDebug: true,
            ),
          ),
        ],
      )),
    ));
  }
}
5
likes
0
pub points
70%
popularity

Publisher

verified publishernovelplotter.com

Wraps text and auto sizes it dynamically with respect to the given dimensions.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, hyphenatorx

More

Packages that depend on text_wrap_auto_size