Skip to content

Commit 2bf41b9

Browse files
committed
Add CI workflow and improve code formatting in examples
Introduces a GitHub Actions CI workflow for linting, testing, and building on multiple platforms. Refactors and formats example Dart files for improved readability and consistency, including expanded widget constructors and better code style in menu, storage, and tray icon examples.
1 parent 95b33df commit 2bf41b9

File tree

17 files changed

+1074
-474
lines changed

17 files changed

+1074
-474
lines changed

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
9+
jobs:
10+
lint:
11+
name: Lint & Analyze
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Flutter
19+
uses: subosito/flutter-action@v2
20+
with:
21+
flutter-version: '3.38.7'
22+
channel: 'stable'
23+
cache: true
24+
25+
- name: Install melos
26+
run: dart pub global activate melos
27+
28+
- name: Add melos to PATH
29+
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
30+
31+
- name: Verify melos installation
32+
run: dart pub global run melos --version
33+
34+
- name: Bootstrap melos
35+
run: dart pub global run melos bootstrap
36+
37+
- name: Check code formatting
38+
run: dart pub global run melos run format
39+
40+
- name: Analyze code
41+
run: dart pub global run melos run analyze
42+
43+
test:
44+
name: Test (${{ matrix.os }})
45+
runs-on: ${{ matrix.os }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
os: [ubuntu-latest, macos-latest, windows-latest]
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
55+
- name: Setup Flutter
56+
uses: subosito/flutter-action@v2
57+
with:
58+
flutter-version: '3.38.7'
59+
channel: 'stable'
60+
cache: true
61+
62+
- name: Install melos
63+
run: dart pub global activate melos
64+
65+
- name: Add melos to PATH
66+
shell: bash
67+
run: |
68+
if [[ "$RUNNER_OS" == "Windows" ]]; then
69+
echo "$USERPROFILE/.pub-cache/bin" >> $GITHUB_PATH
70+
else
71+
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
72+
fi
73+
74+
- name: Verify melos installation
75+
run: dart pub global run melos --version
76+
77+
- name: Bootstrap melos
78+
run: dart pub global run melos bootstrap
79+
80+
- name: Run tests
81+
run: dart pub global run melos run test
82+
83+
build:
84+
name: Build (${{ matrix.os }})
85+
runs-on: ${{ matrix.os }}
86+
needs: [lint, test]
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
os: [ubuntu-latest, macos-latest, windows-latest]
91+
92+
steps:
93+
- name: Checkout repository
94+
uses: actions/checkout@v4
95+
96+
- name: Setup Flutter
97+
uses: subosito/flutter-action@v2
98+
with:
99+
flutter-version: '3.38.7'
100+
channel: 'stable'
101+
cache: true
102+
103+
- name: Install melos
104+
run: dart pub global activate melos
105+
106+
- name: Add melos to PATH
107+
shell: bash
108+
run: |
109+
if [[ "$RUNNER_OS" == "Windows" ]]; then
110+
echo "$USERPROFILE/.pub-cache/bin" >> $GITHUB_PATH
111+
else
112+
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
113+
fi
114+
115+
- name: Bootstrap melos
116+
run: dart pub global run melos bootstrap
117+
118+
- name: Build cnativeapi example Linux
119+
if: matrix.os == 'ubuntu-latest'
120+
run: |
121+
cd packages/cnativeapi/example
122+
flutter build linux --release
123+
124+
- name: Build nativeapi example Linux
125+
if: matrix.os == 'ubuntu-latest'
126+
run: |
127+
cd packages/nativeapi/example
128+
flutter build linux --release
129+
130+
- name: Build cnativeapi example macOS
131+
if: matrix.os == 'macos-latest'
132+
run: |
133+
cd packages/cnativeapi/example
134+
flutter build macos --release
135+
136+
- name: Build nativeapi example macOS
137+
if: matrix.os == 'macos-latest'
138+
run: |
139+
cd packages/nativeapi/example
140+
flutter build macos --release
141+
142+
- name: Build cnativeapi example Windows
143+
if: matrix.os == 'windows-latest'
144+
run: |
145+
cd packages/cnativeapi/example
146+
flutter build windows --release
147+
148+
- name: Build nativeapi example Windows
149+
if: matrix.os == 'windows-latest'
150+
run: |
151+
cd packages/nativeapi/example
152+
flutter build windows --release

examples/display_example/lib/main.dart

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class _DisplayManagerPageState extends State<DisplayManagerPage> {
9494
void _updateCursorAndWindow() {
9595
final displayManager = DisplayManager.instance;
9696
final cursorPos = displayManager.getCursorPosition();
97-
97+
9898
final windowManager = WindowManager.instance;
9999
final currentWindow = windowManager.getCurrent();
100100

@@ -589,10 +589,7 @@ class DisplayCanvas extends StatelessWidget {
589589
width: windowWidth,
590590
height: windowHeight,
591591
decoration: BoxDecoration(
592-
border: Border.all(
593-
color: Colors.orange,
594-
width: 2,
595-
),
592+
border: Border.all(color: Colors.orange, width: 2),
596593
boxShadow: [
597594
BoxShadow(
598595
color: Colors.orange.withOpacity(0.3),
@@ -604,9 +601,7 @@ class DisplayCanvas extends StatelessWidget {
604601
child: Stack(
605602
children: [
606603
// Window background (semi-transparent)
607-
Container(
608-
color: Colors.orange.withOpacity(0.1),
609-
),
604+
Container(color: Colors.orange.withOpacity(0.1)),
610605
// Window title bar indicator
611606
Container(
612607
height: (20 * scale).clamp(8.0, 20.0),
@@ -682,11 +677,7 @@ class DisplayCanvas extends StatelessWidget {
682677
],
683678
),
684679
child: const Center(
685-
child: Icon(
686-
Icons.mouse,
687-
size: 8,
688-
color: Colors.white,
689-
),
680+
child: Icon(Icons.mouse, size: 8, color: Colors.white),
690681
),
691682
),
692683
);

0 commit comments

Comments
 (0)