Skip to content

Commit

Permalink
feat: add flutter_lints, fix or ignore lints (maplibre#414)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Leibiger <kuhnroyal@gmail.com>
  • Loading branch information
2 people authored and remax21 committed Sep 10, 2024
1 parent 4a65602 commit 2ab21a1
Show file tree
Hide file tree
Showing 55 changed files with 307 additions and 277 deletions.
38 changes: 6 additions & 32 deletions .github/workflows/flutter_beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,12 @@ env:
FLUTTER_CHANNEL: 'beta'

jobs:
format:
name: "Check formatting"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Lint analysis
run: flutter format --set-exit-if-changed .

lint:
name: "Static code analysis"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- run: flutter pub get
- name: Lint analysis
run: flutter analyze

build-android:
name: "Build Android apk"
runs-on: ubuntu-latest
defaults:
run:
working-directory: example

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -56,15 +28,18 @@ jobs:
- run: flutter pub get
- name: Build example APK
run: flutter build apk
# We might want to add a flutter test step in the future, when there actually are tests for this plugin
- name: Upload apk as artifact
uses: actions/upload-artifact@v4
with:
name: maplibre-flutter-demo.apk
path: example/build/app/outputs/flutter-apk/app-release.apk

build-iOS:
name: Build iOS package
runs-on: macos-latest
defaults:
run:
working-directory: example

steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
Expand All @@ -80,7 +55,7 @@ jobs:
- name: Upload Runner.app as artifact
uses: actions/upload-artifact@v4
with:
name: Runner.app
name: maplibre-flutter-demo.app
path: example/build/ios/iphonesimulator

build-web:
Expand All @@ -89,7 +64,6 @@ jobs:
defaults:
run:
working-directory: example

steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
Expand Down
50 changes: 26 additions & 24 deletions .github/workflows/flutter_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,25 @@ name: Flutter CI

on: [push, pull_request, workflow_dispatch]

env:
FLUTTER_CHANNEL: 'stable'
FLUTTER_VERSION: '3.10.5'

jobs:
format:
name: "Check formatting"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Lint analysis
run: dart format --set-exit-if-changed .

lint:
name: "Static code analysis"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- run: flutter pub get
- run: |
Expand All @@ -46,37 +36,46 @@ jobs:
defaults:
run:
working-directory: example

strategy:
fail-fast: false
matrix:
sdk: [ '3.10.5', '' ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.sdk }}
cache: true
- uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- run: flutter pub get
- name: Build example APK
run: flutter build apk
# We might want to add a flutter test step in the future, when there actually are tests for this plugin
- name: Upload apk as artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.sdk == '' }}
with:
name: maplibre-flutter-demo.apk
path: example/build/app/outputs/flutter-apk/app-release.apk

build-iOS:
name: Build iOS package
runs-on: macos-latest
defaults:
run:
working-directory: example

strategy:
fail-fast: false
matrix:
sdk: [ '3.10.5', '' ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
flutter-version: ${{ matrix.sdk }}
cache: true
- uses: maxim-lobanov/setup-cocoapods@v1
with:
Expand All @@ -85,9 +84,10 @@ jobs:
- name: Build iOS package
run: flutter build ios --simulator
- name: Upload Runner.app as artifact
if: ${{ matrix.sdk == '' }}
uses: actions/upload-artifact@v4
with:
name: Runner.app
name: maplibre-flutter-demo.app
path: example/build/ios/iphonesimulator

build-web:
Expand All @@ -96,13 +96,15 @@ jobs:
defaults:
run:
working-directory: example

strategy:
fail-fast: false
matrix:
sdk: [ '3.10.5', '' ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
flutter-version: ${{ matrix.sdk }}
cache: true
- run: flutter pub get
- name: Build web
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/formatter.yml

This file was deleted.

7 changes: 7 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
include: package:flutter_lints/flutter.yaml

analyzer:
errors:
# remove once git dependencies have been removed
invalid_dependency: ignore

linter:
rules:
camel_case_types: false
constant_identifier_names: false
30 changes: 15 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:location/location.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:maplibre_gl/maplibre_gl.dart';
import 'package:maplibre_gl_example/attribution.dart';
import 'package:maplibre_gl_example/get_map_informations.dart';
import 'package:maplibre_gl_example/given_bounds.dart';
Expand All @@ -16,26 +17,24 @@ import 'package:maplibre_gl_example/no_location_permission_page.dart';

import 'animate_camera.dart';
import 'annotation_order_maps.dart';
import 'click_annotations.dart';
import 'custom_marker.dart';
import 'full_map.dart';
import 'layer.dart';
import 'line.dart';
import 'local_style.dart';
import 'map_ui.dart';
import 'move_camera.dart';
import 'click_annotations.dart';
import 'offline_regions.dart';
import 'page.dart';
import 'place_batch.dart';
import 'place_circle.dart';
import 'place_fill.dart';
import 'place_source.dart';
import 'place_symbol.dart';
import 'place_fill.dart';
import 'scrolling_map.dart';
import 'offline_regions.dart';
import 'custom_marker.dart';
import 'place_batch.dart';
import 'layer.dart';
import 'sources.dart';

import 'package:maplibre_gl/maplibre_gl.dart';

final List<ExamplePage> _allPages = <ExamplePage>[
const MapUiPage(),
const FullMapPage(),
Expand Down Expand Up @@ -94,13 +93,14 @@ class _MapsDemoState extends State<MapsDemo> {
await location.requestPermission();
}
}
if (!mounted) return;

Navigator.of(context).push(MaterialPageRoute<void>(
if (context.mounted) {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (_) => Scaffold(
appBar: AppBar(title: Text(page.title)),
body: page,
)));
appBar: AppBar(title: Text(page.title)),
body: page,
),
));
}
}

@override
Expand Down
6 changes: 4 additions & 2 deletions example/lib/map_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,10 @@ class MapUiBodyState extends State<MapUiBody> {
debugPrint('# features: ${features.length}');
_clearFill();
if (features.isEmpty && _featureQueryFilter != null) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('QueryRenderedFeatures: No features found!')));
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('QueryRenderedFeatures: No features found!')));
}
} else if (features.isNotEmpty) {
_drawFill(features);
}
Expand Down
4 changes: 2 additions & 2 deletions example/lib/sources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ class FullMapState extends State<FullMap> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Current source ${styleInfo.name}",
textScaleFactor: 1.4,
"Current source: ${styleInfo.name}",
style: Theme.of(context).textTheme.titleLarge,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependency_overrides:
path: ..

dev_dependencies:
flutter_lints: ^2.0.1
flutter_lints: ^3.0.0
flutter_test:
sdk: flutter

Expand Down
9 changes: 6 additions & 3 deletions lib/src/annotation_manager.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of maplibre_gl;
part of '../maplibre_gl.dart';

abstract class AnnotationManager<T extends Annotation> {
final MaplibreMapController controller;
Expand Down Expand Up @@ -186,11 +186,12 @@ class LineManager extends AnnotationManager<Line> {
lineOffset: [Expressions.get, 'lineOffset'],
lineBlur: [Expressions.get, 'lineBlur'],
);

@override
List<LayerProperties> get allLayerProperties => [
_baseProperties,
_baseProperties.copyWith(
LineLayerProperties(linePattern: [Expressions.get, 'linePattern'])),
_baseProperties.copyWith(const LineLayerProperties(
linePattern: [Expressions.get, 'linePattern'])),
];
}

Expand All @@ -205,6 +206,7 @@ class FillManager extends AnnotationManager<Fill> {
enableInteraction: enableInteraction,
selectLayer: (Fill fill) => fill.options.fillPattern == null ? 0 : 1,
);

@override
List<LayerProperties> get allLayerProperties => const [
FillLayerProperties(
Expand All @@ -231,6 +233,7 @@ class CircleManager extends AnnotationManager<Circle> {
enableInteraction: enableInteraction,
onTap: onTap,
);

@override
List<LayerProperties> get allLayerProperties => const [
CircleLayerProperties(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/color_tools.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of maplibre_gl;
part of '../maplibre_gl.dart';

extension MapLibreColorConversion on Color {
String toHexStringRGB() {
Expand Down
Loading

0 comments on commit 2ab21a1

Please sign in to comment.