Flutter基礎控件參數說明

一.Text:文本

1.Text():一個單一樣式的文本

2.Text.rich():使用InlineSpan創建的文本

Text(
    String data;    //文本內容(Text())
    TextSpan textSpan; //文本內容(Text.rich())
    TextStyle style;     //文本樣式
    StrutStyle strutStyle;    //段落樣式
    TextAlign textAlign;    //本文對其方式
    TextDirection textDirection;    //文本方向
    Locale locale;    //選擇區域特定字形的語言環境
    bool softWrap;     //是否自動換行
    TextOverflow overflow;    //如何處理文本溢出
    double textScaleFactor;    //每個邏輯像素的字體像素數
    int maxLines;    //文本的最大行數,如果文本超過給定的行數,則會根據overflow字段截斷
    String semanticsLabel;    //文本的替代語義標籤
)

 二.Image:圖片

 1.Image():用於從ImageProvider獲取圖像

 2.Image.asset():加載圖片資源

 3.Image.file():加載本地圖片文件

 4.Image.network ():加載網絡圖片

 5.Image.memory():加載Uint8List資源圖片

Image(
    ImageProvider<dynamic> image;    //要顯示的圖像(Image())
    String name,    //圖片路徑(Image.asset())
    AssetBundle bundle,    //圖片資源(Image.asset())
    File file;    //文件路徑(Image.file())
    String src;    //圖片地址url(Image.network())
    Uint8List bytes Uint8List;    //獲取的ImageStream,如sdk中從網絡轉Uint8List(Image.memory())
    String semanticLabel;    //圖像的語義描述
    bool excludeFromSemantics;   //是否從語義中排除此圖像,默認false
    double scale;    //比例
    double width;    //寬度
    double height;   //高度
    Color color;    //顏色,如果不爲null,則通過colorBlendMode屬性將此顏色與圖像混合
    BlendMode colorBlendMode;    //混合模式
    BoxFit fit;    //圖像的顯示模式
    AlignmentGeometry alignment;    //對齊方式,默認Alignment.center
    ImageRepeat repeat;    //重複方式,默認ImageRepeat.noRepeat
    Rect centerSlice;     //九宮格拉伸
    bool matchTextDirection;    //是否以文本方向繪製圖片,默認false
    bool gaplessPlayback;       //當圖像更改時,是繼續顯示舊圖像(true)還是簡單地顯示任何內容(false),默認false
    FilterQuality filterQuality;    //篩選質量,默認FilterQuality.low
    String package, //包名(Image.asset())
    Map<String, String> headers;    //參數可用於通過圖像請求發送自定義HTTP標頭(Image.network())
)

三.TextField:輸入框

TextField(
    TextEditingController controller;    //文本編輯控制器
    FocusNode focusNode;    //定義此窗口小部件的鍵盤焦點
    InputDecoration decoration;    //在文本字段周圍顯示的裝飾
    TextInputType keyboardType;    //用於編輯文本的鍵盤類型
    TextInputAction textInputAction;    //用於鍵盤的操作按鈕類型
    TextCapitalization textCapitalization;    //配置平臺鍵盤如何選擇大寫或小寫鍵盤,默認TextCapitalization.none
    TextStyle style;    //文本樣式
    StrutStyle strutStyle;    //用於垂直佈局的支柱樣式
    TextAlign textAlign;    //對齊方式,默認TextAlign.start
    TextDirection textDirection,    //文本的方向性
    bool autofocus;    //是否自動獲取焦點,默認false
    bool obscureText;    //是否隱藏文本(密碼),默認false
    bool autocorrect;    //是否啓用自動更正,默認true
    int maxLines;    //最大行,默認1
    int minLines;    //最小行
    bool expands;    //是否將此窗口小部件的高度調整爲填充其父級,默認false
    int maxLength;    //最大長度
    bool maxLengthEnforced;    //如果爲true,則阻止該字段允許超過maxLength個 字符,默認true
    ValueChanged<String> onChanged;    //當用戶啓動對TextField值的更改時調用:當他們插入或刪除文本時
    VoidCallback onEditingComplete;    //當用戶提交可編輯內容時調用(例如,用戶按下鍵盤上的“完成”按鈕)
    ValueChanged<String> onSubmitted;    //當用戶指示他們已完成編輯字段中的文本時調用
    List<TextInputFormatter> inputFormatters;    //可選的輸入驗證和格式覆蓋
    bool enabled;    //是否可用
    double cursorWidth;    //光標的寬度,默認2.0
    Radius cursorRadius;    //光標的圓角度
    Color cursorColor;    //光標顏色
    Brightness keyboardAppearance;    //鍵盤的外觀
    EdgeInsets scrollPadding;    //此值控制在滾動後TextField將位於Scrollable邊緣的距離,默認EdgeInsets.all(20.0)
    DragStartBehavior dragStartBehavior;    //確定處理拖動開始行爲的方式,默認DragStartBehavior.start
    bool enableInteractiveSelection;    //如果爲true,則長按此TextField將顯示剪切/複製/粘貼菜單,並且點擊將移動文本插入符號
    GestureTapCallback onTap;    //當用戶點擊此文本字段時調用
    InputCounterWidgetBuilder buildCounter;    //生成自定義InputDecorator.counter小部件的回調
    ScrollPhysics scrollPhysics;    //確定Scrollable小部件的物理特性
)

四.Icon:圖標

Icon(
    IconData icon;//系統庫中的圖標文件
    double size;//圖標的尺寸
    Color color;//繪製圖標時使用的顏色
    String semanticLabel;//圖標的語義標籤
    TextDirection textDirection;//用於渲染圖標的文本方向
)

五.IconButton:帶圖標的按鈕

IconButton(
    double iconSize: 24.0;//圖標尺寸
    EdgeInsetsGeometry padding: const EdgeInsets.all(8.0);//內邊距
    AlignmentGeometry alignment: Alignment.center;//對齊方式
    Widget icon;//圖標控件
    Color color;//顏色
    Color highlightColor;//按鈕按下時的顏色
    Color splashColor;//點擊後擴散動畫的顏色
    Color disabledColor;//按鈕不可用時的顏色
    VoidCallback onPressed;//點擊或以其他方式激活按鈕時調用的回調
    String tooltip;//描述按下按鈕時將發生的操作的文本
)

六.RaisedButton:凸起按鈕

1.RaisedButton():帶文本的凸起按鈕

2.RaisedButton.icon():帶文本和圖標的凸起按鈕

RaisedButton(
    requiredVoidCallback onPressed;  //點擊或以其他方式激活按鈕時調用的回調
    ValueChanged<bool> onHighlightChanged;  //由底層InkWell小部件的InkWell.onHighlightChanged 回調調用
    ButtonTextTheme textTheme;  //文本主題
    Color textColor;  //文本顏色
    Color disabledTextColor;  //按鈕不可用時的文本顏色
    Color color;  //按鈕顏色
    Color disabledColor;   //按鈕不可用時的顏色
    Color highlightColor;  //按鈕按下時的顏色
    Color splashColor;     //點擊後擴散動畫的顏色
    Brightness colorBrightness;  //用於此按鈕的主題亮度
    double elevation;  //凸出的高度
    double highlightElevation;  //按下按鈕時凸出的高度
    double disabledElevation;  //按鈕不可用時凸出的高度
    EdgeInsetsGeometry padding;  //內邊距
    ShapeBorder shape;  //按鈕材質的形狀
    Clip clipBehavior: Clip.none;  //剪裁
    MaterialTapTargetSize materialTapTargetSize;  //配置點擊目標的最小尺寸
    Duration animationDuration;  //動畫的持續時間
    Widget child;  //子控件(RaisedButton())
    Widget icon;  //圖標(RaisedButton.icon())
    Widget label;//文本(RaisedButton.icon())
)

七.ListView:列表

1.ListView()

2.ListView.builder()

3.ListView.custom()

4.ListView.separated()

ListView(
    IndexedWidgetBuilder itemBuilder;   //子條目佈局(ListView.builder(),ListView.separated())
    IndexedWidgetBuilder separatorBuilder;   //(ListView.separated())
    SliverChildDelegate childrenDelegate;   //爲ListView提供子代的委託(ListView.custom())
    int itemCount;    //item數量(ListView.bu ilder(),ListView.separated())
    List<Widget> children: const <Widget>[], //子條目佈局(ListView())
    int semanticChildCount,//子條目數量
    Axis scrollDirection: Axis.vertical;//滾動方向
    bool reverse: falsel;//是否反轉滾動方向
    ScrollController controller;//滾動控制器
    bool primary;//如果爲true,即使滾動視圖沒有足夠的內容來實際滾動,滾動視圖也是可滾動的。否則,默認情況下,只有具有足夠內容的用戶才能滾動視圖,取決於physics屬性
    ScrollPhysics physics;//滾動視圖應如何響應用戶輸入
    bool shrinkWrap: false;//是否應該由正在查看的內容確定scrollDirection中滾動視圖的範圍
    EdgeInsetsGeometry padding;//內邊距
    double itemExtent;//滾動方向上的範圍
    bool addAutomaticKeepAlives: true;//是否將每個子項包裝在AutomaticKeepAlive中
    bool addRepaintBoundaries: true;//是否將每個子項包裝在RepaintBoundary中
    bool addSemanticIndexes: true;//是否將每個子項包裝在IndexedSemantics中
    double cacheExtent;//滾動緩存區像素
    DragStartBehavior dragStartBehavior: DragStartBehavior.start;//確定處理拖動開始行爲的方式
)

 本文內容參考了官方api文檔,內容持續更新,部分註釋可能不準確,如果有問題,請通知我修改!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章