पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

fitted_text_field_container कवर
पैकेज विवरणv2.0.0

fitted_text_field_container

एक Container जो स्वचालित रूप से एक Material TextField के पाठ मान के अनुरूप आकार बदलता है।

30-दिन डाउनलोड
45
लाइक
27
Pub अंक
70

पैकेज इंस्टॉल करें

flutter pub add fitted_text_field_container

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

एक फ्लटर पैकेज जो मैटेरियल टेक्स्टफील्ड को एक कंटेनर में लपेटता है जो सामग्री के आकार के अनुसार गतिशील रूप से आकार बदलता है। यह सुनिश्चित करता है कि उपयोगकर्ता टाइप करते समय कंटेनर के आकार स्वचालित रूप से समायोजित होते हैं, बिना हाथ से आकार निर्धारित किए दृश्य सुसंगतता बनाए रखते हैं। जहां स्थान दक्षता और लेआउट प्रतिक्रियाशीलता महत्वपूर्ण हो, वहां फॉर्म और इनपुट फील्ड्स के लिए आदर्श है। पैकेज हल्का है और मौजूदा फ्लटर UI में बिना किसी दिक्कत के एकीकृत होता है।

उपयोग

  • डायनामिक फॉर्म लेआउट
  • प्रतिक्रियाशील इनपुट कंटेनर
  • स्वचालित आकार के पाठ क्षेत्र
  • चर लंबाई के साथ स्पष्ट यूआई डिज़ाइन
  • सीमित स्थानों में इनपुट क्षेत्र

मुख्य विशेषताएँ

  • स्वचालित कंटेनर आकार समायोजन
  • Material TextField एकीकरण
  • हाथ से चौड़ाई/ऊंचाई सेट नहीं करनी है
  • हल्का और सरल
  • फ्लटर के साथ निरंतर सुमेल

इनके लिए उपयुक्त

  • प्रतिक्रियाशील इनपुट कंटेनर की आवश्यकता वाले विकासकर्ता
  • UI डिज़ाइनर स्पष्ट लेआउट पर ध्यान केंद्रित करते हैं
  • चर टेक्स्ट इनपुट वाले फॉर्म बिल्डर
  • न्यूनतम बॉलरप्लेट कोड वाले प्रोजेक्ट्स

विचार योग्य बातें

  • केवल पाठ सामग्री तक सीमित
  • बहुपंक्ति पाठ का समर्थन नहीं करता है
  • कोई निर्मित वैधता या मास्किंग नहीं
  • जटिल फॉर्म तर्क के लिए उपयुक्त नहीं
  • पैरेंट विजेट के निर्देशांक पर निर्भर करता है

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

Fitted TextField Container

A Container that automatically resizes it's width to fit the containing TextField's text value.

Read the short blog: https://medium.com/@huyffs/fitted-textfield-container-for-flutter-c9c63644441c

Usage

FittedTextFieldContainer
Param Type Default Description
child TextField * required The TextField to fit
calculator CalculateFunction FittedTextFieldCalculator.fitVisible A function to calculate the width. The default function fits the visible content & decorations (i.e. it collapses to the content/label's width when hint text disappears)
builder Widget Function(BuildContext context, TextField child) null A builder that can be used to build complex layouts. The child TextField is provided to the build function
Example
FittedTextFieldContainer(
    child: TextField(
        controller: someTextEditingController,
        textAlign: TextAlign.right,
        decoration: InputDecoration(
            prefixText: "£",
            labelText: "Amount",
        ),
    ),
)
AnimatedFittedTextFieldContainer

All params from FittedTextFieldContainer plus the following

Param Type Default Description
growCurve Curve Curves.easeOutCirc The curve to use in the grow animation
growDuration Duration Duration(milliseconds: 300) Duration to animate the container's width when TextField grows
shrinkCurve Curve Curves.easeInCirc The curve to use in the shrink animation
shrinkDuration Duration Duration(milliseconds: 600) Duration to animate the container's width when TextField shrinks
Example
AnimatedFittedTextFieldContainer(
    growDuration: Duration(milliseconds: 300),
    shrinkDuration: Duration(milliseconds: 600),
    growCurve: Curves.easeOutCirc,
    shrinkCurve: Curves.easeInCirc,
    child: TextField(
        controller: someTextEditingController,
        textAlign: TextAlign.right,
        decoration: InputDecoration(
            prefixText: "£",
            labelText: "Amount",
        ),
    ),
)
FittedTextFieldMeasurer

A class that takes a TextField and TextStyle and returns the following measurements:

  • textField The fitted textfield
  • textStyle The fitted textfield's style or the default style
  • textWidth Width of the text content
  • labelWidth Width of the label
  • hintWidth Width of the hint text
  • fixedWidths Width of fixed elements (prefixText, suffixText, contentPadding and cursorWidth)
CalculateFunction

This function takes measured values and returns a width value.

Signature:
double CalculateFunction(FittedTextFieldMeasurer)
Example:
FittedTextFieldContainer(
    calculator: (m) =>
        m.fixedWidths +
        max(m.labelWidth, max(m.hintWidth, m.textWidth)),
    child: TextField(
        controller: someTextEditingController,
        textAlign: TextAlign.right,
        decoration: InputDecoration(
            hintText: "Width of hint text",
        ),
    ),
);
Predefined functions

A few calculators are provided for common use-cases

  • fitAll fits content, label and hint texts
  • fitVisible fits the visible content & decorations (i.e. it collapses to the content/label's width when hint text disappears)
  • fitVisibleWithPadding(double padding) in addition to fitting visible content it adds a fixed padding value
  • fitVisibleWithRange(double min, double max) in addition to fitting visible content it enforces a minimum and (optional) maximum width
Example:

Fit all

FittedTextFieldContainer(
    calculator: FittedTextFieldCalculator.fitAll,
    child: ...
);

Fit visible with minimum

FittedTextFieldContainer(
    calculator: FittedTextFieldCalculator.fitVisibleWithRange(120),
    child: ...
);

Fit visible with maximum

FittedTextFieldContainer(
    calculator: FittedTextFieldCalculator.fitVisibleWithRange(0, 180),
    child: ...
);
Using the builder
AnimatedFittedTextFieldContainer(
    child: TextField(
        controller: someTextEditingController,
        textAlign: TextAlign.right,
        decoration: InputDecoration(
            labelText: "Twinkle twinkle",
        ),
    ),
    builder: (context, child) => Container(
        child: Stack(
            overflow: Overflow.visible,
            children: <Widget>[
                child,
                Positioned(
                    top: 0,
                    right: -22,
                    child: _aniWholePoundCtl.text.isEmpty
                        ? Icon(Icons.star_border)
                        : Icon(Icons.star, color: Colors.amber),
                ),
            ],
        ),
    ),
)

Contribute

Pull requests are welcome!

Licence

MIT License

Copyright (c) 2020 Huy Dinh

श्रेणियाँ

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।