dàn âm thanh hội trường, âm thanh lớp học, âm thanh phòng họp, loa trợ giảng

Flutter Widget Container

Giáo trình tự học Flutter, tự học lập trình Dart, Dart Cheat Sheet

Flutter Widget Container

Flutter Widget Container là một trong những widget cơ bản của Flutter. Widget Container sử dụng để bao (bọc) một widget khác như Text và giúp widget con này có các thuộc tính như margin, padding…

Ví dụ Flutter Widget Container

import 'package:flutter/material.dart';

void main() {
  runApp(ConatinerDemo());
}

class ConatinerDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      // child: Text('Heloo World', textDirection: TextDirection.ltr),
      margin: const EdgeInsets.all(10.0), color: Colors.amber[600], width: 48.0,
      height: 48.0,
    );
  }
}

Các thuộc tính của Flutter Widget Container

Container Container({Key key, AlignmentGeometry alignment, EdgeInsetsGeometry padding, Color color, Decoration decoration, Decoration foregroundDecoration, double width, double height, BoxConstraints constraints, EdgeInsetsGeometry margin, Matrix4 transform, AlignmentGeometry transformAlignment, Widget child, Clip clipBehavior = Clip.none})

Dưới đây là các thuộc tính và phương thức thường gặp của

  • alignment → AlignmentGeometry? Căn lề widget con so với Container (Align the child within the container).
    final
  • child → Widget? Widget con được bao (bọc) bởi container (The child contained by the container).
    final

     

  • color → Color? Màu sắc nền (phía sau) widget child của container (The color to paint behind the child).
    final
  • constraints → BoxConstraints?Additional constraints to apply to the child. […]
    final
  • decoration → Decoration?The decoration to paint behind the child[…]
    final
  • foregroundDecoration → Decoration?The decoration to paint in front of the child.
    final
  • margin → EdgeInsetsGeometry?Empty space to surround the decoration and child.
    final
  • padding → EdgeInsetsGeometry?Empty space to inscribe inside the decoration. The child, if any, is placed inside this padding. […]
    final
  • transform → Matrix4?The transformation matrix to apply before painting the container.
    final
  • transformAlignment → AlignmentGeometry?The alignment of the origin, relative to the size of the container, if transform is specified. […]
    final

Các phương thức của widget Container

  • build(BuildContext context) → Widget. Describes the part of the user interface represented by this widget.
    override
  • createElement() → StatelessElement. Creates a StatelessElement to manage this widget’s location in the tree.
    inherited
  • toString({DiagnosticLevel minLevel: DiagnosticLevel.info}) → String. A string representation of this object. inherited
  • toStringDeep({String prefixLineOne: '', String? prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug}) → String. Returns a string representation of this node and its descendants.
    inherited
  • toStringShort() → String. A short, textual description of this widget.
    inherited
Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts
Tư Vấn App Học Ngoại Ngữ
Phần Mềm Bản Quyền
Chat Ngay