Skip to content

Commit 04ef123

Browse files
authored
Prepare for new version (#688)
* add .vscode with launch.json * update broken link to Spitfire .apk * improve prepare workflow * flutter format
1 parent 1de94ed commit 04ef123

File tree

9 files changed

+110
-36
lines changed

9 files changed

+110
-36
lines changed

.github/workflows/prepare.yaml

+40-6
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,26 @@ on:
1010

1111
jobs:
1212
main:
13+
name: Flutter ${{ matrix.channel }}${{ matrix.version }}
1314
runs-on: ubuntu-latest
1415

16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- channel: stable
21+
- channel: beta
22+
23+
1524
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v2
25+
- name: Clone repository
26+
uses: actions/checkout@v3
1827

19-
- name: Setup Flutter
28+
- name: Install Flutter
2029
uses: subosito/flutter-action@v1
30+
with:
31+
channel: ${{ matrix.channel }}
32+
flutter-version: ${{ matrix.version }}
2133

2234
- name: Flutter version
2335
run: flutter --version
@@ -29,11 +41,33 @@ jobs:
2941
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
3042
restore-keys: ${{ runner.os }}-pub-
3143

32-
- name: Download pub dependencies
44+
- name: flutter pub get
3345
run: flutter pub get
3446

35-
- name: Run analyzer
36-
run: flutter analyze
47+
- name: flutter format
48+
run: flutter format --set-exit-if-changed .
49+
50+
- name: flutter analyze
51+
run: flutter analyze --no-fatal-infos
52+
53+
- name: flutter test
54+
run: flutter test
55+
56+
- name: flutter pub get (example app)
57+
working-directory: ./example
58+
run: flutter pub get
59+
60+
- name: flutter format (example app)
61+
working-directory: ./example
62+
run: flutter format --set-exit-if-changed .
63+
64+
- name: flutter analyze (example app)
65+
working-directory: ./example
66+
run: flutter analyze --no-fatal-infos
67+
68+
- name: flutter test (example app)
69+
working-directory: ./example
70+
run: flutter test
3771

3872
- name: Dry run pub publish
3973
# We don't want it to fail the CI, it's just to see how would `pub publish` behave.

.vscode/launch.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "example",
6+
"cwd": "example",
7+
"request": "launch",
8+
"type": "dart"
9+
},
10+
{
11+
"name": "example (profile)",
12+
"cwd": "example",
13+
"request": "launch",
14+
"type": "dart",
15+
"flutterMode": "profile"
16+
},
17+
{
18+
"name": "example (release)",
19+
"cwd": "example",
20+
"request": "launch",
21+
"type": "dart",
22+
"flutterMode": "release"
23+
}
24+
]
25+
}

example/lib/data.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DownloadItems {
5252
DownloadItem(
5353
name: 'Spitfire',
5454
url:
55-
'https://github.com/bartekpacia/spitfire/releases/download/v1.2/spitfire-android_1.2.apk',
55+
'https://github.com/bartekpacia/spitfire/releases/download/v1.2.0/spitfire.apk',
5656
)
5757
];
5858
}

example/lib/download_list_item.dart

+12-10
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ class DownloadListItem extends StatelessWidget {
4343
constraints: const BoxConstraints(minHeight: 32, minWidth: 32),
4444
icon: const Icon(Icons.play_arrow, color: Colors.green),
4545
),
46-
if (onCancel != null) IconButton(
47-
onPressed: () => onCancel?.call(task),
48-
constraints: const BoxConstraints(minHeight: 32, minWidth: 32),
49-
icon: const Icon(Icons.cancel),
50-
),
46+
if (onCancel != null)
47+
IconButton(
48+
onPressed: () => onCancel?.call(task),
49+
constraints: const BoxConstraints(minHeight: 32, minWidth: 32),
50+
icon: const Icon(Icons.cancel),
51+
),
5152
],
5253
);
5354
} else if (task.status == DownloadTaskStatus.complete) {
@@ -69,11 +70,12 @@ class DownloadListItem extends StatelessWidget {
6970
mainAxisAlignment: MainAxisAlignment.end,
7071
children: [
7172
const Text('Canceled', style: TextStyle(color: Colors.red)),
72-
if (onActionTap != null) IconButton(
73-
onPressed: () => onActionTap?.call(task),
74-
constraints: const BoxConstraints(minHeight: 32, minWidth: 32),
75-
icon: const Icon(Icons.cancel),
76-
)
73+
if (onActionTap != null)
74+
IconButton(
75+
onPressed: () => onActionTap?.call(task),
76+
constraints: const BoxConstraints(minHeight: 32, minWidth: 32),
77+
icon: const Icon(Icons.cancel),
78+
)
7779
],
7880
);
7981
} else if (task.status == DownloadTaskStatus.failed) {

example/lib/home_page.dart

+16-12
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ class _MyHomePageState extends State<MyHomePage> {
125125
_pauseDownload(task);
126126
} else if (task.status == DownloadTaskStatus.paused) {
127127
_resumeDownload(task);
128-
} else if (task.status == DownloadTaskStatus.complete || task.status == DownloadTaskStatus.canceled) {
128+
} else if (task.status == DownloadTaskStatus.complete ||
129+
task.status == DownloadTaskStatus.canceled) {
129130
_delete(task);
130131
} else if (task.status == DownloadTaskStatus.failed) {
131132
_retryDownload(task);
@@ -371,18 +372,21 @@ class _MyHomePageState extends State<MyHomePage> {
371372
appBar: AppBar(
372373
title: Text(widget.title),
373374
actions: [
374-
if (Platform.isIOS) PopupMenuButton<Function>(
375-
icon: const Icon(Icons.more_vert, color: Colors.white),
376-
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
377-
itemBuilder: (context) => [
378-
PopupMenuItem(
379-
onTap: () => exit(0),
380-
child: const ListTile(
381-
title: Text('Simulate App Backgrounded', style: TextStyle(fontSize: 15)),
375+
if (Platform.isIOS)
376+
PopupMenuButton<Function>(
377+
icon: const Icon(Icons.more_vert, color: Colors.white),
378+
shape: RoundedRectangleBorder(
379+
borderRadius: BorderRadius.circular(8)),
380+
itemBuilder: (context) => [
381+
PopupMenuItem(
382+
onTap: () => exit(0),
383+
child: const ListTile(
384+
title: Text('Simulate App Backgrounded',
385+
style: TextStyle(fontSize: 15)),
386+
),
382387
),
383-
),
384-
],
385-
)
388+
],
389+
)
386390
],
387391
),
388392
body: Builder(

example/test/example_test.dart

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
3+
void main() {
4+
test('example test', () {
5+
expect(2 + 2, 4);
6+
});
7+
}

example/test/widget_test.dart

-5
This file was deleted.

lib/src/downloader.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ typedef DownloadCallback = void Function(
1919
/// Provides access to all functions of the plugin in a single place.
2020
class FlutterDownloader {
2121
static const _channel = MethodChannel('vn.hunghd/downloader');
22-
22+
2323
static bool _initialized = false;
2424
static bool get initialized => _initialized;
25-
25+
2626
static bool _debug = false;
2727
static bool get debug => _debug;
2828

test/example_test.dart

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
3+
void main() {
4+
test('example test', () {
5+
expect(2 + 2, 4);
6+
});
7+
}

0 commit comments

Comments
 (0)