The IOS side
1. The ios emulator does not play the keyboard through the shortcut keys: Command + shift + K.Copy the code
The Android end
Copy the code
other
1. If you want to customize the screen adaptation class HYSizeFit(), you need to initialize the corresponding class hysizefit.init () before using internal methods and attributes, such as hysizefit.setpx (). (you can use the extension method available after Dart2.6 here). 2. The JSON received through the API should be converted into model data that Flutter can use; Alternatively, you can get the value from [" attribute name "] without converting. 3. Use the GestureDetector () component solution to make the space produces click effect, add: behaviors: HitTestBehavior. Opaque. 4. No async method can be added to initState() by creating another async method. 5. Round 2 decimal places: toStringAsFixed (2) - type String into a double: a double. The parse () rounded rounded: toStringAsFixed (0) - type String into a double: Int. Parse () other similar; Parse ("2020-12-14 08:38:42"). Parse ("2020-12-12 04:36:23") time.indays: Inhours: indicates the number of hours. InMinutes: indicates the number of minutes. InSeconds: indicates the number of seconds. OnTap: () {navigator.of (context).pushnamed ("/productionDetails", arguments: _productionData); } final Map data = modalroute.of (context).settings.arguments; Arguments: An Object can be passed as multiple arguments. You can use {} or [] wrapped around it. Final Map data = modalroute.of (context).settings.arguments; Final List Data ([] wrap is array) or Final Map data({} wrap is Map). Parent: class HYFather{@override Widget build(BuildContext context) {return Container(child: HYChild(data); // ---- pass multiple arguments child: HYChild(data1,data2); ; }} subcomponent: class HYChild{final Map data; HYChild(this.data); // ---- accepts multiple parameters // Final Map data1; // final Map data2; // HYChild(this.data1,this.data2)} 2) HYChild(this.data1,this.data2)} 3) HYChild(this.data1,this.data2)} 3) HYChild(this.data1,this.data2)} NeverScrollableScrollPhysics (). 1) Pull-up loading: -----stata defines listener: scrollController-_controller; ----- add controller: _controller to listview. builder; ----- initializes the listener in the initState method and listens for the scrolling distance, if greater than the number of API page requests, then requests the next page data: _controller = ScrollController(); _controller.addListener((){ if(_controller.position.pixels >= _controller.position.maxScrollExtent){ _offset += 7; _getProductionData(); }}) 2) drop down refresh: ----- wrap RefreshIndicator() around listvie.Builder; ----- add an implementation method to its property onRefresh onRefresh: _onRefresh; ----- implements the _onRefresh method: first empty the list data, then insert the first 10 items of the latest request, and then continue the pull-up loading logic after displaying. Request ("production/list","GET",params: {"offset": _offset, "limit": _limit}); 11. A baseline aligned attributes: crossAxisAlignment: crossAxisAlignment. Baseline, textBaseline: textBaseline. Ideographic. 12. What is the difference between attributes and variables? Essentially, attributes are used to describe objects, and variables are used more for logical operations. 13. Regarding navigation: Using IndexedStack to maintain page state has the advantage of being simple to configure, but it also has major disadvantages: The child pages managed in IndexedStack are all loaded at once at the beginning, whether or not they are displayed, and the index attribute is used to determine which page to display. 14. Solutions to switching pages to keep the page state: 1) Use the IndexedStack() component to display the index child. The other children are not visible on the page, but the state of all children is preserved by wrapping the current body layer with an IndexedStack. The setState() method only exists in the StatefulWidget. 16. Container() component width: If you do not set the width of the Container component, the width depends on the width of the child components; Set its width to full screen width: width: Mediaquery.of (context).size. Width (or double-.infinity) 17. shared_preferences: ^0.5.12 2) Import 'package:shared_preferences/shared_preferences. Dart '; class Local { static String _token; / / set the token static setToken (token) async {final p1 = await SharedPreferences. GetInstance (); await p1.setString(_token, token); } / / access token static getToken () is async {final p1 = await SharedPreferences. GetInstance (); return p1.getString(_token); } / / delete the token static delToken () is async {final p1 = await SharedPreferences. GetInstance (); p1.remove(_token); }} 3) Use: public class; Settings: Local setToken (data [" content "] [" auth_token "]); Get: local.getToken (). Then ((res){if(res! = null){ setState(() { _token = res; }); }}); // Remove from StatefulWidget: local.delToken () -- About adding multiple attributes: If you add multiple attributes to the public class, the current usage will result in only one attribute being set, overwriting the value of the last attribute; The solution now is to set one of the variables in shared_preferences. Other variables that need to be set and stored are implemented natively in shared_preferences. 18. When the TextFormField() component is used as the input box, the APP will automatically obtain the mouse focus and pop up the keyboard. Set the keyboard to fold up when clicking the blank: wrap the current outermost component with the GestureDetector() component and add behavior: HitTestBehavior.translucent, onTap: () { FocusScope.of(context).requestFocus(FocusNode()); } 19. Remove the handset simulator in the top right corner of the Debug tags, add attributes in materialApp: debugShowCheckedModeBanner: false. 20. About page initialization: 1) Home.dart: The pages property of bottomNavigationBar() component in Scaffold() should be used to initialize these pages. Asynchronous requests in the initState method are also executed. 2) If some of the above asynchronous requests have tokens, the asynchronous request cannot be placed in the initState method, it can be placed in the button event of login and success, and then passed to the home page. Abstract methods must be defined in an abstract class, that is, a method modified with the keyword abstract. 2) After the abstract class is inherited, the abstract method in the abstract class must be implemented; Other methods may not be implemented; 3) Abstract classes are usually used in large API libraries or tool libraries. 22. Why is the build method of the stateFulWidget in state when Flutter is designed? 1) Build widgets that depend on variables in State (State/data); 2) Widgets are constantly destroyed and created during a Flutter operation. They do not want to create a new State when their State changes. 23. About the life cycle of widgets: (mainly for statefulWidgets) 1) The role of the life cycle: initialize some data, variables, and states; Sending network requests; Some events such as controller add add listener events; Manage memory such as timer and controller manual destruction. 2) execution order of statefulwidget lifecycle :(example class name: HYHomeContent) the first is to execute the constructor of HYHomeContent; The second is to implement the createState method of HYHomeContent. The third is the _HYHomeContentState constructor; Fourth, execute the initState method of _HYHomeContentState; Fifth, execute the build method of _HYHomeContentState. Sixth, execute _HYHomeContentState's Dispose method (called when the page is destroyed);Copy the code
List attributes and methods
- attribute
Lenght: indicates the length of the array. First: indicates the first element of the array. Last: indicates the last element of the arrayCopy the code
- methods
AddAll (list) : adds a new array to an array insert(index, value) : adds an element to an array at a specified position, followed by the elements insertAll(index, array) : RemoveAt (index) removeRange(index, index) removeLast() : removeLast() : removeLast() : removeLast() : removeLast() : RemoveWhere ((){}) clear() : remove all elements setRang(index, index, array value) : SetAll (index, array value) : changes the array value after the specified index. ReplaceRange (index, index, value) : Replaces the value of an interval in the array with a value fillRange(index, index, value) : GetRange (index, index) : retrieves the value of an array range sublist(index, index) : retrieves the value of an array range (if there is only one index, it retrieves the value of the index to the end) any((){}) : Contains () : contains an element firstWhere((){},orElse (){}) : contains an element firstWhere((){},orElse (){}) : OrElse lastWhere((){}) : orElse lastWhere((){}) : orElse lastWhere((){}) : orElse lastWhere((){}); IndexWhere((){}, index) : returns the index of the first element that meets the condition. LastIndexWhere ((){}, index) : returns the indexOf the last element that meets the condition, if not present. IndexOf(value, index) : returns the first occurrence indexOf a value starting from the index value, or -1 if not present lastIndexOf() : returns the first occurrence indexOf a value, or -1 if not present lastIndexOf(value, index) : SingleWhere ((){},orElse (){}) : singleWhere((){}) : singleWhere((){}) : singleWhere((){}) : singleWhere((){}); Join () : concatenates the elements in the array with the specified characters toSet() : resets the array forEach() : traverses the array map((e){return}) : Reduce ((val,element){return}) : sort((a,b){return a-b; }) : sort by positive or negative values of the return result in the callbackCopy the code
An error
1. Unhandled Exception: setState() or markNeedsBuild() called during build cause: The parent component has not initialized the setState in initState. Solution: in subcomponents initState adding WidgetsBinding () method. The instance. The addPostFrameCallback ({}) (_), the function placed setState operation in the body. 2. All pages written in the Children property of the IndexedStack of the Home page will be initialized when entering the home page. If there is a case where a previous page needs to be clicked and a value is passed to obtain the value, check if the value is null at initialization time.Copy the code