Created
May 14, 2019 02:10
-
-
Save nvquangth/c1a18eefa76d5c7543aa86a3b2da5034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
fontFamily: "DancingScript" | |
), | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text("Test"), | |
), | |
body: MyHomePage(), | |
), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: _buildT(), | |
); | |
} | |
Widget _buildText() { | |
String s = "The Text widget displays a string of text with single style. " | |
"The string might break across multiple lines or might all " | |
"be displayed on the same line depending on the layout constraints."; | |
return Text( | |
"Hello World", | |
textAlign: TextAlign.left, | |
textScaleFactor: 1.5, | |
style: TextStyle(fontFamily: "DancingScript", fontSize: 30.0), | |
); | |
} | |
TextStyle _buildStyle() { | |
return TextStyle( | |
color: Colors.red, | |
backgroundColor: Color.fromRGBO(255, 20, 20, 0.5), | |
fontSize: 15, | |
fontWeight: FontWeight.bold, | |
wordSpacing: 3, | |
letterSpacing: 10, | |
fontFamily: "DancingScript"); | |
} | |
Widget _buildRichText() { | |
return Text.rich(TextSpan( | |
style: TextStyle(color: Colors.red), | |
semanticsLabel: "Label", | |
text: "Hello World", | |
children: <TextSpan>[ | |
TextSpan(text: "How are you?", style: TextStyle(color: Colors.blue)), | |
TextSpan( | |
text: "I'm fine, thanks", | |
style: TextStyle(fontSize: 20, fontStyle: FontStyle.italic)), | |
TextSpan(text: r'$$', semanticsLabel: "Double Dolar") | |
])); | |
} | |
Widget _buildT() { | |
return Column( | |
children: <Widget>[ | |
_buildFlutter(), | |
_buildGoogle() | |
], | |
); | |
} | |
Widget _buildFlutter() { | |
return Center( | |
child: RichText( | |
text: TextSpan( | |
children: <TextSpan>[ | |
TextSpan(text: " F ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[300])), | |
TextSpan(text: " l ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[400])), | |
TextSpan(text: " u ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[500])), | |
TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[600])), | |
TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[700])), | |
TextSpan(text: " e ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[800])), | |
TextSpan(text: " r ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[900])), | |
] | |
), | |
), | |
); | |
} | |
Widget _buildGoogle() { | |
return Center( | |
child: RichText( | |
text: TextSpan( | |
children: <TextSpan>[ | |
TextSpan(text: "G", | |
style: TextStyle(color: Colors.blue, | |
fontSize: 60, | |
fontWeight: FontWeight.bold,)), | |
TextSpan(text: "o", | |
style: TextStyle(color: Colors.red, | |
fontSize: 60, | |
fontWeight: FontWeight.bold, | |
fontFamily: "DancingScript")), | |
TextSpan(text: "o", | |
style: TextStyle(color: Colors.yellow, | |
fontSize: 60, | |
fontWeight: FontWeight.bold, | |
fontFamily: "DancingScript")), | |
TextSpan(text: "g", | |
style: TextStyle(color: Colors.blue, | |
fontSize: 60, | |
fontWeight: FontWeight.bold,)), | |
TextSpan(text: "l", | |
style: TextStyle(color: Colors.green, | |
fontSize: 60, | |
fontWeight: FontWeight.bold)), | |
TextSpan(text: "e", | |
style: TextStyle(color: Colors.red, | |
fontSize: 60, | |
fontWeight: FontWeight.bold)), | |
] | |
), | |
), | |
); | |
} | |
Widget _buildAwesome() { | |
return Stack( | |
children: <Widget>[ | |
_buildHFlutter(), | |
_buildVFlutter() | |
], | |
); | |
} | |
Widget _buildHFlutter() { | |
return Center( | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
RichText( | |
text: TextSpan(text: " F ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[900])), | |
), | |
RichText( | |
text: TextSpan(text: " l ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[800])), | |
), | |
RichText( | |
text: TextSpan(text: " u ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[700])), | |
), | |
RichText( | |
text: TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[600])), | |
), | |
RichText( | |
text: TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[700])), | |
), | |
RichText( | |
text: TextSpan(text: " e ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[800])), | |
), | |
RichText( | |
text: TextSpan(text: " r ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[900])), | |
), | |
], | |
), | |
); | |
} | |
Widget _buildVFlutter() { | |
return Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
RichText( | |
text: TextSpan(text: " F ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[900])), | |
), | |
RichText( | |
text: TextSpan(text: " l ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[800])), | |
), | |
RichText( | |
text: TextSpan(text: " u ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[700])), | |
), | |
RichText( | |
text: TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[600])), | |
), | |
RichText( | |
text: TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[700])), | |
), | |
RichText( | |
text: TextSpan(text: " e ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[800])), | |
), | |
RichText( | |
text: TextSpan(text: " r ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[900])), | |
), | |
], | |
), | |
); | |
} | |
Widget _buildFlutter2() { | |
return Center( | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
RichText( | |
text: TextSpan( | |
children: <TextSpan>[ | |
TextSpan(text: " F ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[900])), | |
TextSpan(text: " l ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[800])), | |
TextSpan(text: " u ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[700])), | |
TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[600])), | |
TextSpan(text: " t ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[700])), | |
TextSpan(text: " e ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[800])), | |
TextSpan(text: " r ", | |
style: TextStyle(color: Colors.white, | |
fontSize: 60, | |
fontWeight: FontWeight.w300, | |
backgroundColor: Colors.blue[900])), | |
] | |
), | |
) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment