1. Flutter_swiper An error occurs when an asynchronous request is made to display the banner but the initial URL is empty

    Reference: github.com/best-flutte…

    Main: Do not set autoplay when no data is requested. autoplay: _imageUrls.isNotEmpty

  2. Scrollable grid layout font layout

    Reference: CustomScrollView component

  3. The FLUTTER sub-components account for 100% of the viewport

    Reference: MediaQuery) of (context). The size, width,

  4. Flutter component understanding

    Reference: MaterialApp() is equivalent to the root component of HTML; Scaffold() is the equivalent of body

  5. Flutter components declare cycles

    Refer to the official

  6. Use of the FLUTTER JSON parsing tool jSON_model

    Main:

  7. [] and. Operators, slightly different from js

    Reference: www.dartcn.com/guides/lang…

    [] the parties concerned had specified the value at the specified index in the list. . Refers to a property of an expression; example: foo.bar selects property bar from expression foo

  8. Click the event GestureDetector has a small range

    Reference: blog.csdn.net/cpcpcp123/a…

    Behavior: HitTestBehavior. Opaque, property that lets click events pass through the Text area. If you do not add this property, you will only get a response when you click on the text.

  9. Route belt parameter returns; Navigator.push is an asynchronous operation

    Reference: reference source code

    Main: Page1 page needs page2 page to return data, page1 needs to wait for Page2 to return data when jumping

    /// page1 jumps to page2
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) =>
        Page2(params: 'from page1),
      ),
    ).then((data) { /// key: where data is the data returned in page2
      print(data.toString()); });/// page2 Returns page1
    Navigator.pop(context, 'from page2');Copy the code
  10. Widget declaration cycle

    /// StatefullWidget vs StatelessWidgetStatelessWidget: A widget with no intermediate state changes that needs to be updated by re-creating the displaynewFlutter recommends using StatelessWidget StatefullWidget: There are intermediate state changes, so the question arises. Not all widgets are immutable. Where are state changes stored? The classes of state introduced by flutter are used to store intermediate states. This node and the following entire subtree lifecycle of flutter are updated by calling state.setState() : State create didUpdateWidget(newWidget) that is called after the insert into the tree; deactivate() that is called when the ancestor node rebuilds the widget; deactivate() that is called when the widget is removed; Dispose interface before dispose interface is called didChangeDependencies(): When initialized, call immediately after initState() when the InheritedWidget rebuild is used, this interface is called build(): After calling [initState]. After calling [didUpdateWidget]. After receiving a call to [setState]. After a dependency ofthis[State] object changes (e.g., an[InheritedWidget] referenced by the previous [build] changes). After calling [deactivate] and then reinserting the [State] object into the tree at another location. Dispose (): Hot Reload call Notes: Deactivate (), didUpdateWidget(newWidget), build(), and didUpdateWidget(newWidget). When an item in the ListView is rolled out of the displayable area, it will be removed from the tree. All states in the subtree of the item will be disposed. All the data in the state record is destroyed. When the item is rolled back to the displayable area, a new state, Element, and RenderObject are created. If there is a complex resource update in the state that needs to be reloaded to take effect, add a handle to reassemble(), otherwise you might get some unexpected results when you use Hot Reload, such as displaying the contents of a local file on screen. The contents of the file are replaced, but Hot Reload does not trigger a re-reading of the file, and the page displays the same old contentCopy the code
  11. Data from top to bottom. Differences from bidirectional binding.

    Main:

  12. The Icons icon library

    Reference: material. IO/resources/I…

  13. Common components:

    1.Loading: CircularProgressIndicator2.Drop down Refresh: RefreshIndicator3.Events: the GestureDetectorCopy the code
  14. The implementation scheme of top rolling

    1.SliverPersistentHeade is compatible with NestedScrollView

    Reference: CustomScrollView property shrinkWrap: true, which changes the float level of SliverPersistentHeader.

  15. The index method in list.map ()

    Reference: stackoverflow.com/questions/5…

    Main: There is an asMap method that converts a list to a map where the key is the index and the value is the element in the index. Check out the documentation here. Ex. :

    List _sample = ['a'.'b'.'c'];
    _sample.asMap().forEach((index, value) => f);
    Copy the code
    List<Widget> _buildWidgets(List<Object> list) {
        return list
            .asMap()
            .map((index, value) =>
                MapEntry(index, _buildWidget(index, value)))
            .values
            .toList();
    }
    Copy the code

    Alternatively, you can create a synchrogenerator function to return an iterable

    可迭代<MapEntry<int, T>> enumerate<T>(可迭代<T> items) sync* {
      int index = 0;
      for (T item in items) {
        yield MapEntry(index, item);
        index = index + 1; }}//and use it like this.
    var list = enumerate([0.1.3]).map((entry) => Text("index: ${entry.key}, value: ${entry.value}"));
    Copy the code
  16. List two-dimensional expansion

    Reference: juejin. Cn/post / 684490…

    Main: List. Expand ()

  17. Mesh layout child element width and height fit?

  18. TabView cache problems

  19. Usually if you’re using PageView plus BottomNavigationBar or TabBarView plus TabBar you’ll find that when you go to another page, the previous page will be destroyed, and when you go back to the previous page, the page will be rebuilt, The data is then reloaded and the control is re-rendered

    Reference: juejin. Cn/post / 684490…

  20. Keyboard up causes layout overflow

    When the layout height of flutter is set to dead, such as screen height, the layout Overflow message will appear on the page when the flutter keyboard bounds up and blocks the input field. Reason: In Flutter, the keyboard bounced to reduce the Scaffold height and rebuild to resolve the problem1There are two ways to use overflow tips:1) set the resizeToAvoidBottomInset property of Scaffold tofalseThat will not resize when the keyboard pops up2Of (context).viewinsets. Bottom. The layout will be rebuilt when the keyboard ejects, and the mediaQuery.of (context).viewinsets. Bottom variable will be used before the keyboard ejects0The height of the keyboard is the height of the keyboard2You can do this by placing the input box in a scrollable Widget. When the input box gets focus, the system slides it to the viewable areaCopy the code
  21. TextField focus is not aligned with hint

    style: TextStyle(
      fontSize: 16,
      textBaseline: TextBaseline.alphabetic,
    ),
    Copy the code
  22. The problem of ScreenUtil releasing package is probably caused by the incomplete text or font display on the interface after ScreenUtil initialization renders the home page

    Reference: github.com/OpenFlutter…

    Main: Two solutions

    As mentioned in the official issue, MediaQuery is more recommended.windowRetrieving data is independent of the Widget's life cycle, which can cause problems, such as getting high and wide data with the Debug version because the application is slow, and not getting data with the Release version when the application is faster. I am now using SchedulerBinding in iniState. Instance. AddPostFrameCallback initialized () callback, hope for your help.Copy the code
    @hzysunrainI tried to initialize ScreenUtil in didChangeMetrics, But it fires later than build (on the few occasions THAT I've tried) and even my didChangeMetrics in Myapp is called after the build method of home and ideally it's initialized in home(usually the startup page), But without using ScreenUtil(to avoid special cases where screen data is not available), you should be able to use it directly on the next page of the launch pageCopy the code

23. Use SingleChildScrollView and Column to scroll the page. Can set the physics of the ListView to NeverScrollableScrollPhysics, SingleChildScrollView AlwaysScrollableScrollPhysics physics.

ListView, GridView, TabBarView, and other widgets do not have their own height. You must specify the parent component height. If you want to set the dynamic height in Column, you can use Expanded nesting.