当前位置:网站首页>10 useful flutter widgets

10 useful flutter widgets

2022-06-09 11:21:00 Hua Weiyun

10 A useful Flutter The widget

Trying to learn a new language can be frightening and boring . A lot of times , We hope we know some of the features that existed earlier . In today's article , I'll tell you some of the most convenient things I'd like to know earlier Flutter The widget .

Spacer

Spacer Create an adjustable blank space , It occupies Flex Any remaining space between small parts of the container , For example, rows or columns .

​ Row(        children: const <Widget>[          Text('Begin'),          Spacer(), // Defaults to a flex of one.          Text('Middle'),          // Gives twice the space between Middle and End than Begin and Middle.          Spacer(flex: 2),          Text('End'),        ],      ),

TextButton.icon

When creating a button with an icon , This widget replaces the need to use rows . You must provide icons and labels .

TextButton.icon(              onPressed: () {},               icon: Icon(Icons.home),               label: Text('Home')              ),

Wrap

It displays its children horizontally or vertically according to the direction value provided . It can be used instead of Gridview. This widget is responsive , You don't have to do much to adapt to different screen sizes .

Wrap(                direction: Axis.horizontal,                alignment: WrapAlignment.start,                spacing: 2.0,                runSpacing: 3.0,                children: [],              )

AnimatedSwitcher

This widget animates a new widget to replace another . It provides a good transition , Make the application very smooth . Always add a key to its child widget to make sure it works .

SafeArea

This widget adds padding to your widget , Make sure your application doesn't interact with the operating system and device display functions ( Such as the status bar ) conflict .

SafeArea(child: Container())

RefreshIndicator

Use the scrollable widget as a child . When the child is over rolled , The animated circular progress indicator fades into the view and invokes the future to update scrollable content .

RefreshIndicator(child: ListView(), onRefresh: () async {}),

RichText

This allows us to display text with different styles on the same sentence or paragraph . You can include inline links 、 Underline text 、 Color text, etc .

Transform

This widget takes your animation game to a whole new level . It can realize simple animation , Such as rotating and scaling to more complex animation , Such as 3D And tilt animation . It provides useful named constructors , For example, rotation 、 Zoom and pan , So as to realize .


InteractiveViewer

Introducing scaling on widgets 、 translation 、 The simplest way to drag and knead functions . It can be highly customized according to your needs .

Flow

This widget uses the power of transformation to provide cool animation . It is one of the widgets you must see in practice to understand its functionality . see Official documents For more insights .

Chip

This is a simple widget , Display simple data in an organized and elegant way . It has several variants , for example InputChipChoiceChipFilterChip and ActionChip.

Chip(   avatar: CircleAvatar(     backgroundColor: Colors.grey.shade800,     child: const Text('AB'),   ),   label: const Text('Aaron Burr'), )

Now you know some really cool widgets , Let's make better use of Flutter Come on! .


原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091027221444.html