Friday, August 14, 2020

Text || RichText Widget

 Text Widget 

................................................................................................................................................................................................................................
Example: #1[]

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
home: MyApp(),
));

class MyApp extends StatefulWidget {
@override
MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hello World!'),
),
body: Container(
child: Align(
alignment: Alignment.center,
child: Text(
'Hello World! Hello World! Hello World! Hello World!',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 40,
color: Colors.blue,
decoration: TextDecoration.combine([
TextDecoration.overline,
TextDecoration.underline,
]),

decorationThickness: 2.0,
decorationColor: Colors.red,
decorationStyle: TextDecorationStyle.wavy,
letterSpacing: 5.0,
wordSpacing: 10.0,
shadows: [
Shadow(
color: Colors.black,
blurRadius: 2.0,
offset: Offset(2,1)
)
]
),
textAlign: TextAlign.justify,
maxLines: 2,
overflow: TextOverflow.ellipsis,
textScaleFactor: 2,

),
),
),
);
}
}
................................................................................................................................................................................................................................
Example: #2[]
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main()=>runApp(MaterialApp(home: MyApp(),));

class MyApp extends StatefulWidget {
@override
MyAppState createState()=>MyAppState();
}
class MyAppState extends State<MyApp>{
final TapGestureRecognizer _gestureRecognizer = TapGestureRecognizer()..onTap=(){
debugPrint('Hello World');
};

Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: Text('RichText'),
),
body: Center(
child: Container(
child: RichText(
text: TextSpan(
text: "don't have an account? ",
style: TextStyle(color: Colors.black),
children: [
TextSpan(
text: 'Register', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blue),
recognizer:_gestureRecognizer
),
]
),
),
),
),
);
}
}
................................................................................................................................................................................................................................
Example: #3[]
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main()=>runApp(MaterialApp(home: MyApp(),));

class MyApp extends StatefulWidget {
@override
MyAppState createState()=>MyAppState();
}
class MyAppState extends State<MyApp>{
final TapGestureRecognizer _gestureRecognizer = TapGestureRecognizer()..onTap=(){
debugPrint('Hello World');
};

Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: Text('RichText'),
),
body: Center(
child: Container(
child: RichText(
text: TextSpan(
text: "Share ",
style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 40.0),
children: [
WidgetSpan(
child: Icon(Icons.share,
),
alignment: PlaceholderAlignment.middle
),
]
),
),
),
),
);
}
}


................................................................................................................................................................................................................................
Example: #3[]



No comments:

Post a Comment