RichText විජට් එක විවිධ මෝස්තර භාවිතා කරන පෙළ සංදර්ශන කිරීමට භාවිතා කරයි. ප්රදර්ශනය කරන ලද පෙළ විස්තර කර ඇත්තේ TextSpan වස්තු වල ගසක් භාවිතයෙන් වන අතර, ඒ සෑම එකක්ම එම උප වෘක්ෂය සඳහා භාවිතා කරන තමන්ගේම ආශ්රිත ශෛලියක් ඇත. පිරිසැලසුම් සීමාවන් මත පදනම්ව, පෙළ පේළි කිහිපයක් හරහා කැඩී යා හැක, නැතහොත් සියල්ල එකම පේළියක පෙන්විය හැක.
Constructors:
Syntax:
RichText(
{Key key,
@required InlineSpan text,
TextAlign textAlign: TextAlign.start,
TextDirection textDirection,
bool softWrap: true,
TextOverflow overflow:
TextOverflow.clip,
double textScaleFactor: 1.0,
int maxLines,
Locale locale,
StrutStyle strutStyle,
TextWidthBasis textWidthBasis: TextWidthBasis.parent,
TextHeightBehavior textHeightBehavior,
Properties:
-
children: The widgets below this widget in the tree.
-
hashCode: The hash code for this object.
-
key: Controls how one widget replaces another widget in the tree.
-
runtimeType: A representation of the runtime type of the object.
-
text: The text to display in this widget.
-
textAlign: How the text should be aligned horizontally.
-
local: This property takes in Locale class as the object. It controls the font used for the text depending on the language used.
-
maxLines: The maxLines property takes in an int value as the object. It controls the maximum number of lines that can be there for the text to expand and wrap.
-
overflow: TextOverflow enum is the object given to its class it controls the text in case of overflow.
-
softWrap: This property takes in a boolean value as the object. If it is set to false the gulphs in the text become wider.
-
textDirection: This property takes in TextDirection class as the object to decide the direction of the text. It can be either from left-to-right or right-to-left.
-
textHightBehaviour: TextHeightBehavior class is the object given to this property. It controls how the text will be highlighted.
-
textScaleFactor: This property is taken in a double value as the object to determine the relative size of the font.
-
textWidthBasis: TextWidthBasis enum is the object of this property. It controls the width of a single line of text being measured.
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); // This widget is //the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'ClipOval', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePAGE(), debugShowCheckedModeBanner: false, ); } } class MyHomePAGE extends StatefulWidget { const MyHomePAGE({Key? key}) : super(key: key); @override // ignore: library_private_types_in_public_api _MyHomePAGEState createState() => _MyHomePAGEState(); } class _MyHomePAGEState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(‘Apps Lanka Dev’'), backgroundColor: Colors.green, ), body: Center( child: RichText( // Controls visual overflow overflow: TextOverflow.clip, // Controls how the text should be aligned horizontally textAlign: TextAlign.end, // Control the text direction textDirection: TextDirection.rtl, // Whether the text should break at soft line breaks softWrap: true, // Maximum number of lines for the text to span maxLines: 1, // The number of font pixels for each logical pixel textScaleFactor: 1, text: TextSpan( text: 'Hello ', style: DefaultTextStyle.of(context).style, children: const [ TextSpan( text: 'Apps Lanka Dev', style: TextStyle(fontWeight: FontWeight.bold)), ], ), )), backgroundColor: Colors.lightBlue[50], ); } } class MyClip extends CustomClipper { @override Rect getClip(Size size) { return const Rect.fromLTWH(0, 0, 100, 100); } @override bool shouldReclip(oldClipper) { return false; } }
We are developing Mobile application and Web application for more details visit our web site www.appslanka.lk
0 Comments