当前位置:网站首页>Flutter assembly
Flutter assembly
2022-06-25 16:08:00 【. calin.】
Set the background color
Container(
decoration: new BoxDecoration(color: Colors.pink),
child: Column(
children: [
title(‘3D Interaction ’),
title(‘ Start training mode ’),
title(‘ The background music ’),
title(‘ common problem ’),
],
),
appBar: AppBar(
backgroundColor: Colors.redAccent,
title: Text(‘ motion ’),
leading: Icon(Icons.ac_unit, color: Colors.white),
)
Container
- The function is all ready
- Set up text Inside and outside the margin
EdgeInsets.fromLTRB(10,10,10,10) ,L It means the left margin (left abbreviation ),T Indicates the top margin (top abbreviation ),R Indicates the right margin (right abbreviation ),B Indicates the bottom margin (bottom abbreviation ), The four values can be written separately ;
EdgeInsets.all(10), The top, bottom, left and right margins are 10;
EdgeInsets.only(left: 10, right: 5, top: 10, bottom: 10), Can be specified separately 4 The margin value in each direction , If you only need the top margin , It can be written. EdgeInsets.only( top: 10);
EdgeInsets.symmetric(vertical: 20, horizontal: 10) , You can specify the vertical and horizontal margins , You can also specify the vertical or horizontal margins separately . For example, only the vertical margin is required , Can be written as EdgeInsets.symmetric(vertical: 20);
EdgeInsets.fromWindowPadding(), Create a that matches the given window fill insets. The specific usage is still unknown , The first parameter is given widget Of windowpadding, The second is the screen resolution
3. Interval use SizedBox(width: 10),
Here are someInline code slice.
new Container(
constraints: new BoxConstraints.expand(
height:Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0,
),
decoration: new BoxDecoration(
border: new Border.all(width: 2.0, color: Colors.red),
color: Colors.grey,
borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
image: new DecorationImage(
image: new NetworkImage('http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg'),
centerSlice: new Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),
),
),
padding: const EdgeInsets.all(8.0),
alignment: Alignment.center,
child: new Text('Hello World',
style: Theme.of(context).textTheme.display1.copyWith(color: Colors.black)),
transform: new Matrix4.rotationZ(0.3),
)
Container Of alignment Didn't work , Because Container The size of is not set , Or the size just wraps around the child elements
appbar attribute
1. Common properties Insert the code slice description here
.leading left Element customization , It's a widget parts
leadingWidth AppBar Of leading Width , If leading If there are words in , If you don't set this property , When you have a lot of words , It will change lines
title AppBar The title of the , Also a widget
titleSpacing Set up AppBar The title of the Open the left and right On both sides distance
centerTitle control AppBar Whether the title of is centered , Boolean value , Default false,
actins AppBar Additional part on the right , Like a button , A word, etc , Need to pass in a List( Array )
backgroundColor AppBar Background color of , Pass in a Color The color of the type , Such as Colors.red, Color(0xff45ff41)
elevation AppBar Bottom of Shadow size , The default is 4.0, Set to 0.0 Hui He body The elements in are linked together
shadowColor AppBar Bottom of Shadow color , Same as backgroundColor Parameter usage
toolbarHeight Set up AppBar Of components Height , Pass in double Type of value , Such as 25, 40.2
2.
appbar Of title Centering centerTitle: true, Don't need to use margin: const EdgeInsets.only(left: 100, right: 0, top: 10, bottom: 10)
3.
appbar How to set the height of :
In the AppBar Before to add appBar: PreferredSize(preferredSize: Size.fromHeight(10),child: AppBar( But in general ,appbar The height is the same
row The two ends of the sub assembly are aligned
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(value),
Icon(Icons.arrow_forward_ios)
],
)
4. There are setState Method , To write to a class
5.color: Colors.#F6F6F6-----color: Color(0xffF6F6F6)
6.ClipRRect No cutting container,contanner Set rounded border
Cannot provide both a color and a decoration
7. Picture set click event and jump
InkWell(
child: Icon(Icons.arrow_forward_ios,size: 15,),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyHomePage2(),
),
);
listview
scrollDirection: Axis.horizontal,
1. Implement roughly the same list ,ListTile yes cell( Each one item) Is a fixed row height . adopt scrollDirection Property can be set to horizontal list
2. children Parameters , It accepts a Widget list (List). This approach is suitable for situations where only a small number of subcomponents are known and relatively small , On the contrary, you should use ListView.builder Dynamically build list items on demand .
3. ListView.builder Of itemCount Is a must
4.listviw To give length , Otherwise... Cannot be displayed
5. All attributes :
leading, cell Icon on the left
title, cell Main title
subtitle, cell Subtitle
trailing, cell Right icon
isThreeLine = false, cell Whether to display in three lines
dense, cell Intuitive feeling is the overall size
contentPadding, cell Content margins
enabled = true, cell Can I respond to
onTap, cell onTap cell Click event
onLongPress, cell onLongPress Long press event
selected = false, cell Check the status
6.
listview Do not fix the height , Just use expand
7.
listview It contains listview. In it list view It contains a container, And specify the height .
ListTile
const ListTile({
Key key,
this.leading, //title Previous widget
this.title, // The main contents of the list block
this.subtitle, //title The contents shown below
this.trailing, // After the title widget, It's usually a [Icon]widget
this.isThreeLine = false, // Are you going to display three lines of text
this.dense, // Whether this list block is part of a vertically dense list , If it is true The text will be smaller
this.visualDensity,
this.shape,
this.contentPadding, // Margin between content and border , The default is 16
this.enabled = true, // Whether the list block is interactive
this.onTap, // When the user clicks this list block, call
this.onLongPress, // When the user presses and holds this list block, call
this.mouseCursor,
this.selected = false, // If the list block... Is selected , The color of the text and icon will become the main color of the theme
this.focusColor,
this.hoverColor,
this.focusNode,
this.autofocus = false,
})
Text
Text(value,style: TextStyle(
fontSize: 14,
color: Color(0xff4F6770),
fontFamily: "PingFang SC",)),
)
Click event
InkWell(
child: buildButtonColum(Icons.call, 'CALL'),
onTap:(){
print('CALL');
},
),
Image
'image/one.png', height: 10,
width: 10,
Two centered
Container(
height: 32,
width: 109,
alignment: Alignment.center,
decoration: new BoxDecoration(
color: Color(articlecolor),
borderRadius: new BorderRadius.all(new Radius.circular(10.0)),
),
child: Text(' article ',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Color(0xff4F6770),
fontFamily: "PingFang SC",
)),
),
textAlign: TextAlign.center, Just center the text , Because it only occupies one line , So it doesn't center vertically in the container
Wrap
Wrap The child controls can be laid out horizontally or vertically , And when the space runs out ,Wrap It will wrap itself , It is also often said that streaming Layout .
wheel
https://zhuanlan.zhihu.com/p/90035192
Name of wheel :percent_indicator
Wheel overview :flutter A circular and linear progress bar .
Stack
CustomPaint
It can be called the originator of animation , It can achieve any cool animation and effects .CustomPaint It has no animation properties , Just draw attributes , In general ,CustomPaint Can be used with animation control , Achieve the desired results .
TabBar、TabBarView,TabController
Provides common multi Tab Switching function , For example, the clothes marked horizontally above the e-commerce website 、 furniture 、 Electronic products, … Wait to switch pages , Then click on the corresponding tab Switch to different special sessions .
Integrated monitoring App Crash function
import ‘package:flutter_bugly/flutter_bugly.dart’;
flustars
Depend on Dart Common tool class library common_utils, And encapsulating other third-party libraries , We are committed to sharing simple and easy-to-use tools
1、SpUtil : Single case " Sync "SharedPreferences Tool class . Support get Pass in the default value , Support storage objects , Supports storing object arrays .
2、ScreenUtil : Screen adaptation , Get screen width 、 high 、 density ,AppBar high , Status bar height , Screen orientation .
3、WidgetUtil : monitor Widget Render states , obtain Widget Wide and high , Coordinates on the screen , Get network / Local picture size .
4、DioUtil : Single case Dio Network tools ( Migrated here DioUtil).
5、ImageUtil : Get network / Local picture size .
Bidirectional data binding code
TextField(
style: const TextStyle(color: Color(0xFFA7ABBB),fontSize: 15),
inputFormatters: [DecimalInputFormat(decimalRange: 4)],
keyboardType: TextInputType.numberWithOptions(signed: true),
controller: TextEditingController.fromValue(TextEditingValue(
text: item['number'],
selection: TextSelection.fromPosition(TextPosition(
affinity: TextAffinity.downstream,
offset: item['number'].length)
))
),
decoration: InputDecoration(
counterText: '',
filled: true,
fillColor: Color(0xFF1A1A1A),
hintStyle: const TextStyle(color: Color(0xFFA7ABBB),fontSize: 15),
hintText: ' Please enter the quantity ',
contentPadding: EdgeInsets.symmetric(horizontal: 15,vertical: 10),
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(6),borderSide: BorderSide.none),
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(6),borderSide: BorderSide.none),
suffixIcon: Container(alignment: Alignment.centerRight,child: Text('XBIT',style: const TextStyle(color: Color(0xFFA7ABBB),fontSize: 15),),margin: EdgeInsets.only(right: 15),),
suffixIconConstraints: BoxConstraints(maxWidth: 80)
),
onChanged: (v){undefined
item['number'] = v;
setState(() { });
},
)
text field
Realization text field The inner string is cleared , First, two-way data binding ,
2.
Click again on the textfield The cursor will go to the front , To be in contraner Set cursor in
controller: TextEditingController.fromValue(
TextEditingValue(
selection: TextSelection.fromPosition(
TextPosition(offset: _controller.length)),
text: _controller,
)),
3.
controller: TextEditingController.fromValue(TextEditingValue(
text: controller,
// selection: TextSelection.fromPosition(TextPosition(
// affinity: TextAffinity.downstream,
// offset: item[‘number’].length)
)),
Historical record
bug: //searchHistory.add(str); // Can't add in Unsupported operation: Cannot add to an unmodifiable list
SpUtil.putStringList(‘search_history_list’, […searchHistory, str]);// Direct use ... Syntax addition generates an array
Delete the contents of the hard disk with SpUtil.remove(‘search_history_list’); But the memory value is not deleted , So it won't disappear immediately ,final Can't change the direction , But you can use an array of clear Method empty
Interface
The data format returned by the interface is json, It needs to be serialized to be rendered
json Convert to module class , because sdk The problem of high version leads to the risk that null values are not allowed
Methods for parent-child components to pass values , no need provider, Instead, the parent and child components get variables , because provider, After killing the process, the history is gone
Scloolbar
Add a slider to use , This must be a rollable component of the package , Other components do not work ; The direction of the slider cannot be set ,
The direction of the slider is in the direction of scrolling , So set the scrolling direction of the scrolling component
debug, Algorithm
Common problems in algorithms : Traversal array , But in the process of changing the number of array elements
RangeError (index): Invalid value: Not in inclusive range 0…12: 13 #0 List.[] (dart:core-patch/array.dart:268:52)
List searchedData; searchedData.add(initData[“problem”][“list”][i]); Unable to add ; should List searchedData = [];
sp_util
import ‘package:sp_util/sp_util.dart’;
bool isLooked = SpUtil.getBool(‘is_looked’);
SpUtil.putBool(‘is_looked’, true);
SpUtil.remove(‘search_history_list’);
边栏推荐
- Go language - what is critical resource security?
- 面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
- Optimization of lazyagg query rewriting in parsing data warehouse
- Lecun predicts AgI: big model and reinforcement learning are both ramps! My "world model" is the new way
- The paid video at station B caused the up master to lose more than ten thousand fans
- What plug-ins are available for vscade?
- Built in methods for data types
- GO语言-锁操作
- 加载本地cifar10 数据集
- DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection翻译
猜你喜欢

合宙Air32F103CBT6开发板上手报告

The style of the mall can also change a lot. DIY can learn about it!

10 Super VIM plug-ins, I can't put them down

基于神经标签搜索,中科院&微软亚研零样本多语言抽取式摘要入选ACL 2022
Client development (electron) system level API usage

The paid video at station B caused the up master to lose more than ten thousand fans

Understand the execution sequence of try catch finally in one diagram

Read the configuration, explain the principle and read the interview questions. I can only help you here...

Share the code technology points and software usage of socket multi client communication

Helsinki traffic safety improvement project deploys velodyne lidar Intelligent Infrastructure Solution
随机推荐
f_ Read function [easy to understand]
Helsinki traffic safety improvement project deploys velodyne lidar Intelligent Infrastructure Solution
Mixed density network (MDN) for multiple regression explanation and code example
Traversal and branch judgment of JS (case on June 24, 2022)
Time wheel and implementation analysis of time wheel in go zero
TensorFlow加载cifar10数据集
Problems caused by using ApplicationContext to render layout
Report on Hezhou air32f103cbt6 development board
Go language - lock operation
地理位置数据存储方案——Redis GEO
一文带你搞懂 JWT 常见概念 & 优缺点
QC, QA, IPQC, JQE, DQA, SQE, DQC, MQC, IQC, FQC, OQC
一行代码可以做什么?
AutoK3s v0.5.0 发布 延续简约和友好
When inputting text in the shutter textfield, if the page is refreshed, the cursor position will change.
Describe your understanding of the evolution process and internal structure of the method area
The release of autok3s v0.5.0 continues to be simple and friendly
leetcode-8. String to integer (ATOI)
Native JS dynamically add elements
Optimization of lazyagg query rewriting in parsing data warehouse