The Flutter startup page is displayed modified – Android

  1. Modify the style file
  • Open the style file configured in AndroidManifest MainActivity and add it to the parent of the LaunchTheme.FullscreenSpecific operations are as follows:
<? The XML version = "1.0" encoding = "utf-8"? > <resources> <! -- Theme applied to the Android Window while the process is starting --> <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen"> <! -- Show a splash screen on the activity. Automatically removed when Flutter draws its first frame --> <item name="android:windowBackground">@drawable/launch_background</item> </style> <! -- Theme applied to the Android Window as soon as the process has started. This theme determines the color of the Android Window while your Flutter UI initializes, as well as behind your Flutter UI while its running. This Theme is only used starting with V2 of Flutter's Android embedding. --> <style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen"> <item name="android:windowBackground">@android:color/white</item> </style> </resources>Copy the code
  1. Modify launch_background
<? The XML version = "1.0" encoding = "utf-8"? > <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque"> <item android:drawable="@drawable/launch_gray" /> <! <item android:bottom="298dp" Android :left=" 63DP "Android :right=" 63DP" Android :top=" 194DP "> <bitmap android:gravity="center" android:src="@mipmap/launch_pager_icon" /> </item> <! -- -- -- > at the bottom of the < item android: bottom = "35.5 dp" > < bitmap android: gravity = "center" | bottom android: SRC = "@ mipmap/launch_pager_btm" android:tileMode="disabled" /> </item> </layer-list>Copy the code
  1. Add in the colors file
<drawable name="launch_gray">#AABBCC</drawable>
Copy the code
  1. Add image resources

  1. The effect

Common components of flutter

TextField Input text is vertically centered

TextField by default has padding underneath it, so add a parameter in the InputDecoration and set the padding to 0

contentPadding: EdgeInsets.all(0)
Copy the code

AppBarLeading Overflow overflow problem solved when neutron elements of leading component are too wide

The default width of the leading element is 56. If the width of your ChildWidget exceeds 56, overflow will be reported. Default and fixed leading

1. If leadingWidth = 0, select * from leadingWidth (leading! = null) { leading = ConstrainedBox( constraints: BoxConstraints.tightFor(width: widget.leadingWidth ?? _kLeadingWidth), child: leading, ); } 2. Const double _kLeadingWidth = kToolbarHeight; // So the leading button is square. 3. KToolbarHeight = 56.0 [AppBar]. Const double kToolbarHeight = 56.0;Copy the code

Set the leading width to the AppBar property:

LeadingWidth: XXX,// XXX fill in your actual widthCopy the code

Disallow PageView from scrolling

Add the following code to the PageView property:

physics: NeverScrollableScrollPhysics(),
Copy the code

List calls map to access both index and value

list.asMap().entries.map((entry) {
    int index = entry.key;
    String value = entry.value;
    return something;
}
Copy the code

A Flutter ignores empty safety to create Pigeon

Add –no-sound-safety after the run command

flutter pub run --no-sound-null-safety pigeon \
  --input pigeons/message.dart \
  --dart_out lib/pigeons/message.dart \
  --objc_header_out ios/Classes/messages.h \
  --objc_source_out ios/Classes/messages.m \
  --objc_prefix FLT \
  --java_out android/app/src/main/kotlin/com/zhou/mineplayer/Messages.java \
  --java_package "com.zhou.mineplayer"
Copy the code