2023年2月28日星期二

Reverse list on Top in ListView.builder in Flutter

 Apart from reversing the list, another solution could be putting the ListView inside an Align widget with alignment: Alignment.topCenter . Also shrinkWrap: true needed inside ListView.

         Align(
            alignment: Alignment.topCenter,
            child: ListView.builder(
              reverse: true,
              shrinkWrap: true,
              ...
              ...
           )
         )

2023年2月26日星期日

Name of image in drawable folder red (Android Studio)

 Are you using a version control system? On my Android Studio setup, red files are files that have not yet been added to git.


Right click the file > Git > Add

2023年2月21日星期二

flutter TTS android manifest

 Although probably not the best answer (or maybe just a glitch on Androids part) add the following code just above the <application in your manifest.

<queries>
    <intent>
        <action android:name="android.intent.action.TTS_SERVICE" />
    </intent>
</queries>

2023年2月16日星期四

[Fix] The name 'platformViewRegistry' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix.

 Edit use analysis_options.yaml

analyzer:
  errors:
    undefined_prefixed_name: ignore


[Fix] Execution failed for task ':app:compileDebugKotlin'.

 dd ext.kotlin_version and kotlin dependency in <app>/android/build.gradle file.


buildscript {

ext.kotlin_version = '1.6.21' //use latest original 1.5.0

...

}

dependencies {

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

...

}

x

2023年2月14日星期二

Making an widget disabled / grayed out(grey)

 Container(

  foregroundDecoration: BoxDecoration(
    color: Colors.grey,
    backgroundBlendMode: BlendMode.saturation,
  ),
  child: child,
)

解决Flutter上架Google Play提示Version code 1 has already been used. Try another version code.

 首先我们得搞清楚Flutter中的版本是如何管理的。


Flutter打包的版本名和版本号默认是从pubspec.yaml中的version读取的。我们只需要更新它的值就可以了。


格式为


version:A.B.C+X


对于Android的版本来说,版本号的管理在app/build.gradle中配置。


android{

    defaultConfig {

        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).

        applicationId "com.exmaple.demo"

        minSdkVersion 21

        targetSdkVersion 31

        versionCode flutterVersionCode.toInteger()

        versionName flutterVersionName

    }

}


A.B.C代表了verisonName,比如默认初始值为1.0.0.

X代表versionCode,默认值从1开始,依次累加。

默认App的versionName为1.0.0,versionCode为1。


解决方案

因为对于默认的versionName来说,后面不加上versionCode,versionCode就会默认为1.所以1.0.0和1.0.0+1是没有任何区别的。


我们只需要在versionCode后面加上更大的数字即可。比如+2.


name: flutter_demo

description: A new Flutter application for Flutter demo


# The following line prevents the package from being accidentally published to

# pub.dev using `pub publish`. This is preferred for private packages.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev


# The following defines the version and build number for your application.

# A version number is three numbers separated by dots, like 1.2.43

# followed by an optional build number separated by a +.

# Both the version and the builder number may be overridden in flutter

# build by specifying --build-name and --build-number, respectively.

# In Android, build-name is used as versionName while build-number used as versionCode.

# Read more about Android versioning at https://developer.android.com/studio/publish/versioning

# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.

# Read more about iOS versioning at

# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

# 1更改为2

version: 1.0.0+2