Skip to content

Commit bcc1104

Browse files
authored
Merge pull request #631 from Baseflow/feature/analysis-options
migrate to flutter lints
2 parents 54eee1c + 7e3c53f commit bcc1104

21 files changed

+519
-58
lines changed

.github/workflows/app_facing_package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: app_facing_package
44
# events but only for the develop branch
55
on:
66
push:
7-
branches: [ develop ]
7+
branches: [ develop, master ]
88
paths:
99
- 'cached_network_image/**'
1010
pull_request:
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: platform_interface
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the develop branch
5+
on:
6+
push:
7+
branches: [ develop, master ]
8+
paths:
9+
- 'cached_network_image_platform_interface/**'
10+
pull_request:
11+
branches: [ develop ]
12+
paths:
13+
- 'cached_network_image_platform_interface/**'
14+
15+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
16+
jobs:
17+
format:
18+
name: Format
19+
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
env:
24+
source-directory: ./cached_network_image_platform_interface
25+
26+
# Steps represent a sequence of tasks that will be executed as part of the job
27+
steps:
28+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29+
- uses: actions/checkout@v2
30+
31+
# Make sure the stable version of Flutter is available
32+
- uses: subosito/flutter-action@v1
33+
with:
34+
channel: 'stable'
35+
36+
# Download all Flutter packages
37+
- name: Download dependencies
38+
run: flutter pub get
39+
working-directory: ${{env.source-directory}}
40+
41+
# Run Flutter Format to ensure formatting is valid
42+
- name: Run Flutter Format
43+
run: flutter format --set-exit-if-changed .
44+
working-directory: ${{env.source-directory}}
45+
46+
analyze:
47+
name: Analyze
48+
49+
# The type of runner that the job will run on
50+
runs-on: ubuntu-latest
51+
52+
env:
53+
source-directory: ./cached_network_image_platform_interface
54+
55+
# Steps represent a sequence of tasks that will be executed as part of the job
56+
steps:
57+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
58+
- uses: actions/checkout@v2
59+
60+
# Make sure the stable version of Flutter is available
61+
- uses: subosito/flutter-action@v1
62+
with:
63+
channel: 'stable'
64+
65+
# Download all Flutter packages
66+
- name: Download dependencies
67+
run: flutter pub get
68+
working-directory: ${{env.source-directory}}
69+
70+
# Run Flutter Analyzer
71+
- name: Run Flutter Analyzer
72+
run: flutter analyze
73+
working-directory: ${{env.source-directory}}
74+
75+
tests:
76+
name: Unit-tests
77+
# The type of runner that the job will run on
78+
runs-on: ubuntu-latest
79+
80+
env:
81+
source-directory: ./cached_network_image_platform_interface
82+
83+
# Steps represent a sequence of tasks that will be executed as part of the job
84+
steps:
85+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
86+
- uses: actions/checkout@v2
87+
88+
# Make sure the stable version of Flutter is available
89+
- uses: subosito/flutter-action@v1
90+
with:
91+
channel: 'stable'
92+
93+
# Download all Flutter packages
94+
- name: Download dependencies
95+
run: flutter pub get
96+
working-directory: ${{env.source-directory}}
97+
98+
# Run all unit-tests with code coverage
99+
- name: Run unit tests
100+
run: flutter test --coverage
101+
working-directory: ${{env.source-directory}}
102+
103+
# Upload code coverage information
104+
- uses: codecov/codecov-action@v1
105+
with:
106+
file: ${{env.source-directory}}/coverage/lcov.info # optional
107+
name: CachedNetworkImage (Platform interface) # optional
108+
fail_ci_if_error: true

.github/workflows/web.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: web
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the develop branch
5+
on:
6+
push:
7+
branches: [ develop, master ]
8+
paths:
9+
- 'cached_network_image_web/**'
10+
pull_request:
11+
branches: [ develop ]
12+
paths:
13+
- 'cached_network_image_web/**'
14+
15+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
16+
jobs:
17+
format:
18+
name: Format
19+
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
env:
24+
source-directory: ./cached_network_image_web
25+
26+
# Steps represent a sequence of tasks that will be executed as part of the job
27+
steps:
28+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29+
- uses: actions/checkout@v2
30+
31+
# Make sure the stable version of Flutter is available
32+
- uses: subosito/flutter-action@v1
33+
with:
34+
channel: 'stable'
35+
36+
# Download all Flutter packages
37+
- name: Download dependencies
38+
run: flutter pub get
39+
working-directory: ${{env.source-directory}}
40+
41+
# Run Flutter Format to ensure formatting is valid
42+
- name: Run Flutter Format
43+
run: flutter format --set-exit-if-changed .
44+
working-directory: ${{env.source-directory}}
45+
46+
analyze:
47+
name: Analyze
48+
49+
# The type of runner that the job will run on
50+
runs-on: ubuntu-latest
51+
52+
env:
53+
source-directory: ./cached_network_image_web
54+
55+
# Steps represent a sequence of tasks that will be executed as part of the job
56+
steps:
57+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
58+
- uses: actions/checkout@v2
59+
60+
# Make sure the stable version of Flutter is available
61+
- uses: subosito/flutter-action@v1
62+
with:
63+
channel: 'stable'
64+
65+
# Download all Flutter packages
66+
- name: Download dependencies
67+
run: flutter pub get
68+
working-directory: ${{env.source-directory}}
69+
70+
# Run Flutter Analyzer
71+
- name: Run Flutter Analyzer
72+
run: flutter analyze
73+
working-directory: ${{env.source-directory}}
74+
75+
tests:
76+
name: Unit-tests
77+
# The type of runner that the job will run on
78+
runs-on: macos-latest
79+
80+
env:
81+
source-directory: ./cached_network_image_web
82+
83+
# Steps represent a sequence of tasks that will be executed as part of the job
84+
steps:
85+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
86+
- uses: actions/checkout@v2
87+
88+
# Make sure the stable version of Flutter is available
89+
- uses: subosito/flutter-action@v1
90+
with:
91+
channel: 'stable'
92+
93+
# Download all Flutter packages
94+
- name: Download dependencies
95+
run: flutter pub get
96+
working-directory: ${{env.source-directory}}
97+
98+
# Run all unit-tests with code coverage
99+
- name: Run unit tests
100+
run: flutter test --platform chrome
101+
working-directory: ${{env.source-directory}}
102+
103+
# # Upload code coverage information
104+
# - uses: codecov/codecov-action@v1
105+
# with:
106+
# file: ${{env.source-directory}}/coverage/lcov.info # optional
107+
# name: CachedNetworkImage (Web) # optional
108+
# fail_ci_if_error: true
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:pedantic/analysis_options.1.9.0.yaml
1+
include: package:flutter_lints/flutter.yaml
22
linter:
33
rules:
44
- public_member_api_docs
@@ -8,14 +8,4 @@ analyzer:
88
# Ignore generated files
99
- '**/*.g.dart'
1010
- 'lib/src/generated/*.dart'
11-
errors:
12-
dead_code: warning
13-
invalid_assignment: warning
14-
invalid_override_of_non_virtual_member: error
15-
missing_required_param: error
16-
missing_return: error
17-
todo: info
18-
undefined_function: ignore # TODO: Remove when https://github.com/flutter/flutter/issues/52899 is solved
19-
unused_import: warning
20-
unused_local_variable: warning
2111

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:flutter_lints/flutter.yaml

cached_network_image/example/lib/main.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ void main() {
1919

2020
/// Demonstrates a [StatelessWidget] containing [CachedNetworkImage]
2121
class BasicContent extends StatelessWidget {
22+
const BasicContent({Key? key}) : super(key: key);
23+
2224
static ExamplePage createPage() {
23-
return ExamplePage(Icons.image, (context) => BasicContent());
25+
return ExamplePage(Icons.image, (context) => const BasicContent());
2426
}
2527

2628
@override
@@ -145,8 +147,10 @@ class BasicContent extends StatelessWidget {
145147

146148
/// Demonstrates a [ListView] containing [CachedNetworkImage]
147149
class ListContent extends StatelessWidget {
150+
const ListContent({Key? key}) : super(key: key);
151+
148152
static ExamplePage createPage() {
149-
return ExamplePage(Icons.list, (context) => ListContent());
153+
return ExamplePage(Icons.list, (context) => const ListContent());
150154
}
151155

152156
@override
@@ -173,8 +177,10 @@ class ListContent extends StatelessWidget {
173177

174178
/// Demonstrates a [GridView] containing [CachedNetworkImage]
175179
class GridContent extends StatelessWidget {
180+
const GridContent({Key? key}) : super(key: key);
181+
176182
static ExamplePage createPage() {
177-
return ExamplePage(Icons.grid_on, (context) => GridContent());
183+
return ExamplePage(Icons.grid_on, (context) => const GridContent());
178184
}
179185

180186
@override
@@ -198,7 +204,6 @@ class GridContent extends StatelessWidget {
198204
}
199205

200206
Widget _error(BuildContext context, String url, dynamic error) {
201-
print(error);
202207
return const Center(child: Icon(Icons.error));
203208
}
204209
}

cached_network_image/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies:
2121
dev_dependencies:
2222
flutter_test:
2323
sdk: flutter
24+
flutter_lints: ^1.0.4
2425

2526

2627
# For information on the generic Dart part of this file, see the

cached_network_image/lib/src/image_provider/_image_loader.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:cached_network_image_platform_interface'
1212
'/cached_network_image_platform_interface.dart'
1313
show ImageRenderMethodForWeb;
1414

15+
/// ImageLoader class to load images on IO platforms.
1516
class ImageLoader implements platform.ImageLoader {
1617
@override
1718
Stream<ui.Codec> loadAsync(

cached_network_image/lib/src/image_provider/cached_network_image_provider.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CachedNetworkImageProvider
3636
this.imageRenderMethodForWeb = ImageRenderMethodForWeb.HtmlImage,
3737
});
3838

39+
/// CacheManager from which the image files are loaded.
3940
final BaseCacheManager? cacheManager;
4041

4142
/// Web url of the image to load
@@ -53,10 +54,15 @@ class CachedNetworkImageProvider
5354
/// Set headers for the image provider, for example for authentication
5455
final Map<String, String>? headers;
5556

57+
/// Maximum height of the loaded image. If not null and using an
58+
/// [ImageCacheManager] the image is resized on disk to fit the height.
5659
final int? maxHeight;
5760

61+
/// Maximum width of the loaded image. If not null and using an
62+
/// [ImageCacheManager] the image is resized on disk to fit the width.
5863
final int? maxWidth;
5964

65+
/// Render option for images on the web platform.
6066
final ImageRenderMethodForWeb imageRenderMethodForWeb;
6167

6268
@override

cached_network_image/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dev_dependencies:
1717
flutter_test:
1818
sdk: flutter
1919
mocktail: ^0.1.1
20-
pedantic: ^1.11.0
20+
flutter_lints: ^1.0.4
2121
file: ^6.1.0
2222

2323
environment:

0 commit comments

Comments
 (0)