2025年6月27日星期五

最常用的 8 種 Git Commit 類型

 

最常用的 8 種 Git Commit 類型 📜

這 8 種是你在日常開發中最常遇到和使用的類型,涵蓋了絕大多數的變更:
  1. feat: 🚀 - 新增使用者可見的功能。
  2. fix: 🐛 - 修復程式碼中的錯誤。
  3. docs: 📚 - 文件變更(如 README、程式碼註釋)。
  4. style: ✨ - 只影響程式碼格式的變更,不改變邏輯。
  5. refactor: 🏗️ - 重構程式碼,不影響功能,也不修復 Bug。
  6. perf: ⚡ - 效能優化。
  7. test: ✅ - 新增或修改測試。
  8. chore: 🛠️ - 其他維護性任務(如更新依賴、構建工具配置等),不影響生產程式碼或測試。

2025年6月17日星期二

pop all dialog

 Navigator.of(context).popUntil((route) {

  // Check if the current route is NOT a DialogRoute.
// This means we stop popping when we hit a regular page/widget route.
return route is! DialogRoute;
});

2025年6月11日星期三

Flutter Android App Signing

 1- Generate and get .jks from android studio.

2- Create a key.properties under android file as following format.

storePassword=
keyPassword=
keyAlias=
storeFile= //file path of jks

3- Go to your app level build gradle and get key.properties with following code.

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

4- Add signing configurations inside the android tag.

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}

5- Make sure about your signingConfig is release as following ;

buildTypes {
release {
signingConfig signingConfigs.release
}
}

6- Run ‘flutter build appbundle’ command .

2025年5月29日星期四

detect "returned to the app" , "App went to background" (didChangeAppLifecycleState) (iOS & Android work)

class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {


 @override

void initState() {
  super.initState();
  WidgetsBinding.instance!.addObserver(this);
}

// ...

@override
void dispose() {
  WidgetsBinding.instance!.removeObserver(this);
  super.dispose();
}


@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
print('AppLifecycleState: $state');
if (state == AppLifecycleState.resumed) {
// User has returned to the app (app is in the foreground and active)
print('myState: User returned to the app!');
// Perform actions here, e.g., refresh data, show a message, etc.
} else if (state == AppLifecycleState.paused) {
// App is in the background
print('myState: App went to background');
} else if (state == AppLifecycleState.inactive) {
// App is inactive (e.g., a phone call came in, or app is about to go to background)
print('myState: App is inactive');
}
}

2025年2月12日星期三

(debug mode normal, release mode grey ) Another exception was thrown: Instance of 'DiagnosticsProperty'

 進入debug模式進行調試發現錯誤


======== Exception caught by widgets library =======================================================

The following assertion was thrown while applying parent data.:

Incorrect use of ParentDataWidget.


The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type StackParentData.


Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.

The offending Expanded is currently placed inside a Stack widget.



針對Exception 處理問題

2025年1月13日星期一

BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file

 android > gradle > wrapper > gradle-wrapper.properties 

#distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip