首页 > 其他分享 >Flutter Widgets

Flutter Widgets

时间:2023-01-02 18:44:28浏览次数:31  
标签:widget inside Flutter widgets Widgets app

Learn the basic concept of Flutter widgets and different ways of use it to make user interface.
In Flutter, almost everything is a widget. In this tutorial, you will learn the concept of the widget, methods to use and create it, and types of widgets in the Flutter framework.

If you are building a user interface in Flutter, it will be using widgets. There are different kinds of widgets available on Flutter which has a different kind of purpose, you have to build an app out of those widgets.

In an app, widgets are nested inside one another, even the outermost parent component of the app is also a widget and all inside the app are also widgets. See the tree diagram and the code below to understand the structure of the app using widgets.

image
The above tree of widgets will look like below on code:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
       home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(

       appBar: AppBar( //appbar widget inside Scaffold
         title: Text("Welcome to Flutter")
       ),

       drawer:  Drawer(), //drawer widget inside scaffold

       floatingActionButton: FloatingActionButton( //floating action button widget
         child: Icon(Icons.add), //Icon widget inside Floating action button widget
         onPressed: (){
            //gesture listiner action
         },
       ),
       body: Container(  //container widget on body of scaffold
          child: Column( //multi chidl widget 
            children: [
                Text("Column 1"),
                Text("Column 2"),
          ],)
       )
    );
  }
}

Types of Widgets:
There are two types of widgets in flutter according to their nature.

Visible Widgets (Input and Output)
Invisible Widgets (Layout and Control)
Visible Widgets:

Visible widgets are those widgets that are easily visible whenever we put them inside the widget tree. They are used for displaying information or to take information/input from users. Some of the visible widgets are Text, Button, Image, Icon, etc.

Invisible Widgets:

Invisible widgets are those widgets that are not visible in the widget tree but are used to format, sizing, and locating the visible widgets. Some of the invisible widgets are Scaffold, Row, Column, Padding, SizedBox, etc.

image

标签:widget,inside,Flutter,widgets,Widgets,app
From: https://www.cnblogs.com/ukzq/p/17020338.html

相关文章

  • Flutter 陈航 11-生命周期 WidgetsBindingObserver
    本文地址目录目录目录11|提到生命周期,我们是在说什么?State生命周期生命周期流程图生命周期的三个阶段创建更新销毁注意!!!常见场景的生命周期生命周期方法总结测试代码S......
  • Flutter异常监控 - 壹 | 从Zone说起
    开启掘金成长之旅!这是我参与「掘金日新计划·12月更文挑战」的第3天,点击查看活动详情如果你正需要处理Flutter异常捕获,那么恭喜你,找对地了,这里从根源上给你准备了Flutt......
  • 第144期:flutter的导航和路由
    封面图那些封控做核酸的日子,仿佛还在昨天。这几天核酸检测点撤掉之后,仿佛疫情根本没有发生过一样~导航和路由Flutter提供了一个完整的用于在屏幕之间导航和处理深层链接的系......
  • 第145期:Flutter中的状态
    封面图窗外是一所小学,这两天那座教学楼的墙上多了个校训,我总是把【脚踏实地】看成【实训基地】~状态管理对于经常写​​Vue​​​和​​React​​项目的同学来说,状态管理这个......
  • 第143期:flutter中的资源和图片
    封面图下个季度的目标是把前端监控相关的内容梳理出来,梳理出来之后可能会在公司内部做个分享~Flutter应用程序既括代码也包括一些其他的资产,我们通常这些资产为资源。有时候......
  • 第142期:flutter的状态组件和状态管理
    封面图我们在看电影的时候,往往只关注某个主演的角色,其实那些小角色的表演,远远比主演角色的表演要丰富~场景怎样才能在我们的flutter应用中对用户输入做出响应?比如我们有个图......
  • Flutter异常监控 - 贰 | 框架Catcher原理分析
    前言在给Flutter应用做异常监控的时候,一开始我是拒绝滴,如果不考虑FlutterEngine和native侧的监控,用我另一篇文章中不得不知道的Flutter异常捕获知识点提到的方......
  • 记Flutter执行flutter doctor --android-licenses时出现错误
    错误描述今天刚刚安装好Flutter,执行了$flutterdoctor结果如图所示,出现一个Android令牌状态不可知的错误。根据提示信息,执行如下的命令,$flutterdoctor--android-......
  • Flutter 实现 “真” 3D 动画效果,用纯代码实现立体 Dash 和 3D Logo
    我正在参加「创意开发投稿大赛」详情请看:​​掘金创意开发大赛来了!​​本篇将给你带来更加炫酷动画效果,最后教你如何通过纯代码实现一只立体的Flutter的吉祥物Dash和3......
  • Flutter如何调试应用【Dart Observatory 】以及调试模式断言
    Flutter如何调试应用我们上面写了Flutter测试应用,这远远不够,这篇,我们来写一下Flutter如何调试应用:voidsomeFunction(doubleoffset){debugger(when:offset>30.0);......