一直有聽說flutter超厲害的,今天也開始記錄一下每天的學(xué)習(xí)成果。從零開始學(xué)習(xí)峰锁,不知道是不是從入門到放棄。哈哈哈...
廢話不多說双戳,搭好環(huán)境開始學(xué)習(xí)今天第一個(gè)控件虹蒋。
-------------------------------------又是分隔線------------------------------------------
Text
決定先寫個(gè)“hello world”
//導(dǎo)包
import 'package:flutter/material.dart';
//=>這個(gè)是簡寫,當(dāng)方法后只有一行的時(shí)候可以使用
void main() => runApp(MyText());
/**
* Text屬性:
*style//樣式 【祥見style屬性】
*textAlign//對齊方式,( left:左對齊飒货;right:右對齊魄衅;center:居中對齊;<--
-->justify:自適應(yīng)塘辅;start:文本開頭晃虫,和textDirection有關(guān);end:文本結(jié)尾莫辨,傲茄,和textDirection有關(guān)毅访;)
*textDirection//文本方向,(rtl:right to left 從右向左;ltr:left to right 從左向右)
*softWrap//是否換行顯示,(true換行,false不換行)
*overflow//超出文本的處理方式,(TextOverflow.ellipsis, //以...結(jié)束)
*textScaleFactor//每個(gè)邏輯像素的字體像素?cái)?shù)盘榨,控制字體大小,
*maxLines//最大行數(shù),
*
* style屬性:
* inherit: true,
*color//顏色,
*fontSize//大小喻粹,默認(rèn)10像素,
*fontWeight, //字體粗細(xì) 粗體和正常
*fontStyle,//文字樣式,斜體和正常
*letterSpacing//字間距,負(fù)數(shù)會(huì)讓間距更小
*wordSpacing//字符間距,
*textBaseline,
*height,
*decoration,
*decorationColor,//線的顏色
*decorationStyle,
*debugLabel,
* String fontFamily//字體,
* String package,
*/
class MyText extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
title: "Text",
home: Scaffold(
body: Center(
child: Text(
"hello world",
textAlign: TextAlign.center, //對齊方式
style: TextStyle(fontSize: 20, color: Colors.deepOrangeAccent),
),
),
),
);
}
}