Skip to content

Commit

Permalink
[v2.2.0] Stricten Lints & Fix Tests Exceptions (#1319)
Browse files Browse the repository at this point in the history
* chore: strong-mode is deprecated

* fix: Exception on flutter_map_test

* chore: Example has the same rules as the package

* refacto: replace dynamic by the right type

* Change OverlayImage to BaseOverlayImage

* fix: compareTo is useless now

Co-authored-by: Polo <[email protected]>

* Update analysis_options.yaml

* Readded ignore close_sinks

* Add same rules of pana

Co-authored-by: Luka S <[email protected]>
Co-authored-by: Polo <[email protected]>
  • Loading branch information
3 people authored Aug 2, 2022
1 parent 2d2a956 commit 30ca5de
Show file tree
Hide file tree
Showing 48 changed files with 463 additions and 459 deletions.
24 changes: 16 additions & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
include: package:flutter_lints/flutter.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
close_sinks: ignore
missing_required_param: error
missing_return: error

linter:
rules:
prefer_final_locals: true
prefer_final_in_for_each: true
avoid_dynamic_calls: true
always_declare_return_types: true
always_use_package_imports: true
type_annotate_public_apis: true
avoid_dynamic_calls: true
cancel_subscriptions: true
close_sinks: true
package_api_docs: true
prefer_constructors_over_static_methods: true
prefer_final_in_for_each: true
prefer_final_locals: true
prefer_int_literals: true
test_types_in_equals: true
throw_in_finally: true
type_annotate_public_apis: true
unnecessary_statements: true
use_named_constants: true
28 changes: 27 additions & 1 deletion example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
missing_required_param: error
missing_return: error

linter:
rules:
library_private_types_in_public_api: false
library_private_types_in_public_api: false # Not relevant to the example

always_declare_return_types: true
always_use_package_imports: true
avoid_dynamic_calls: true
cancel_subscriptions: true
close_sinks: false
package_api_docs: true
prefer_constructors_over_static_methods: true
prefer_final_in_for_each: true
prefer_final_locals: true
prefer_int_literals: true
test_types_in_equals: true
throw_in_finally: true
type_annotate_public_apis: true
unnecessary_statements: true
use_named_constants: true
62 changes: 31 additions & 31 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import 'package:flutter/material.dart';

import 'package:flutter_map_example/pages/animated_map_controller.dart';
import 'package:flutter_map_example/pages/circle.dart';
import 'package:flutter_map_example/pages/custom_crs/custom_crs.dart';
import 'package:flutter_map_example/pages/epsg3413_crs.dart';
import 'package:flutter_map_example/pages/epsg4326_crs.dart';
import 'package:flutter_map_example/pages/esri.dart';
import 'package:flutter_map_example/pages/home.dart';
import 'package:flutter_map_example/pages/interactive_test_page.dart';
import 'package:flutter_map_example/pages/live_location.dart';
import 'package:flutter_map_example/pages/many_markers.dart';
import 'package:flutter_map_example/pages/map_controller.dart';
import 'package:flutter_map_example/pages/map_inside_listview.dart';
import 'package:flutter_map_example/pages/marker_anchor.dart';
import 'package:flutter_map_example/pages/marker_rotate.dart';
import 'package:flutter_map_example/pages/max_bounds.dart';
import 'package:flutter_map_example/pages/moving_markers.dart';
import 'package:flutter_map_example/pages/network_tile_provider.dart';
import 'package:flutter_map_example/pages/offline_map.dart';
import 'package:flutter_map_example/pages/on_tap.dart';
import 'package:flutter_map_example/pages/overlay_image.dart';
import 'package:flutter_map_example/pages/plugin_api.dart';
import 'package:flutter_map_example/pages/plugin_scalebar.dart';
import 'package:flutter_map_example/pages/plugin_zoombuttons.dart';
import 'package:flutter_map_example/pages/point_to_latlng.dart';

import './pages/animated_map_controller.dart';
import './pages/circle.dart';
import './pages/custom_crs/custom_crs.dart';
import './pages/esri.dart';
import './pages/home.dart';
import './pages/interactive_test_page.dart';
import './pages/live_location.dart';
import './pages/many_markers.dart';
import './pages/map_controller.dart';
import './pages/marker_anchor.dart';
import './pages/marker_rotate.dart';
import './pages/max_bounds.dart';
import './pages/moving_markers.dart';
import './pages/offline_map.dart';
import './pages/on_tap.dart';
import './pages/overlay_image.dart';
import './pages/plugin_api.dart';
import './pages/plugin_scalebar.dart';
import './pages/plugin_zoombuttons.dart';
import './pages/polygon.dart';
import './pages/polyline.dart';
import './pages/reset_tile_layer.dart';
import './pages/sliding_map.dart';
import './pages/stateful_markers.dart';
import './pages/tap_to_add.dart';
import './pages/tile_builder_example.dart';
import './pages/tile_loading_error_handle.dart';
import './pages/widgets.dart';
import './pages/wms_tile_layer.dart';
import './pages/epsg3413_crs.dart';
import 'package:flutter_map_example/pages/polygon.dart';
import 'package:flutter_map_example/pages/polyline.dart';
import 'package:flutter_map_example/pages/reset_tile_layer.dart';
import 'package:flutter_map_example/pages/sliding_map.dart';
import 'package:flutter_map_example/pages/stateful_markers.dart';
import 'package:flutter_map_example/pages/tap_to_add.dart';
import 'package:flutter_map_example/pages/tile_builder_example.dart';
import 'package:flutter_map_example/pages/tile_loading_error_handle.dart';
import 'package:flutter_map_example/pages/widgets.dart';
import 'package:flutter_map_example/pages/wms_tile_layer.dart';

void main() => runApp(const MyApp());

Expand Down
47 changes: 23 additions & 24 deletions example/lib/pages/animated_map_controller.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_example/widgets/drawer.dart';
import 'package:latlong2/latlong.dart';

import '../widgets/drawer.dart';

class AnimatedMapControllerPage extends StatefulWidget {
static const String route = 'map_controller_animated';

Expand Down Expand Up @@ -49,11 +48,11 @@ class AnimatedMapControllerPageState extends State<AnimatedMapControllerPage>
final zoomTween = Tween<double>(begin: mapController.zoom, end: destZoom);

// Create a animation controller that has a duration and a TickerProvider.
var controller = AnimationController(
final controller = AnimationController(
duration: const Duration(milliseconds: 500), vsync: this);
// The animation determines what path the animation will take. You can try different Curves values, although I found
// fastOutSlowIn to be my favorite.
Animation<double> animation =
final Animation<double> animation =
CurvedAnimation(parent: controller, curve: Curves.fastOutSlowIn);

controller.addListener(() {
Expand All @@ -75,28 +74,28 @@ class AnimatedMapControllerPageState extends State<AnimatedMapControllerPage>

@override
Widget build(BuildContext context) {
var markers = <Marker>[
final markers = <Marker>[
Marker(
width: 80.0,
height: 80.0,
width: 80,
height: 80,
point: london,
builder: (ctx) => Container(
key: const Key('blue'),
child: const FlutterLogo(),
),
),
Marker(
width: 80.0,
height: 80.0,
width: 80,
height: 80,
point: dublin,
builder: (ctx) => const FlutterLogo(
key: Key('green'),
textColor: Colors.green,
),
),
Marker(
width: 80.0,
height: 80.0,
width: 80,
height: 80,
point: paris,
builder: (ctx) => Container(
key: const Key('purple'),
Expand All @@ -109,61 +108,61 @@ class AnimatedMapControllerPageState extends State<AnimatedMapControllerPage>
appBar: AppBar(title: const Text('Animated MapController')),
drawer: buildDrawer(context, AnimatedMapControllerPage.route),
body: Padding(
padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
padding: const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
children: <Widget>[
MaterialButton(
onPressed: () {
_animatedMapMove(london, 10.0);
_animatedMapMove(london, 10);
},
child: const Text('London'),
),
MaterialButton(
onPressed: () {
_animatedMapMove(paris, 5.0);
_animatedMapMove(paris, 5);
},
child: const Text('Paris'),
),
MaterialButton(
onPressed: () {
_animatedMapMove(dublin, 5.0);
_animatedMapMove(dublin, 5);
},
child: const Text('Dublin'),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
padding: const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
children: <Widget>[
MaterialButton(
onPressed: () {
var bounds = LatLngBounds();
final bounds = LatLngBounds();
bounds.extend(dublin);
bounds.extend(paris);
bounds.extend(london);
mapController.fitBounds(
bounds,
options: const FitBoundsOptions(
padding: EdgeInsets.only(left: 15.0, right: 15.0),
padding: EdgeInsets.only(left: 15, right: 15),
),
);
},
child: const Text('Fit Bounds'),
),
MaterialButton(
onPressed: () {
var bounds = LatLngBounds();
final bounds = LatLngBounds();
bounds.extend(dublin);
bounds.extend(paris);
bounds.extend(london);

var centerZoom =
final centerZoom =
mapController.centerZoomFitBounds(bounds);
_animatedMapMove(centerZoom.center, centerZoom.zoom);
},
Expand All @@ -177,9 +176,9 @@ class AnimatedMapControllerPageState extends State<AnimatedMapControllerPage>
mapController: mapController,
options: MapOptions(
center: LatLng(51.5, -0.09),
zoom: 5.0,
maxZoom: 10.0,
minZoom: 3.0),
zoom: 5,
maxZoom: 10,
minZoom: 3),
layers: [
TileLayerOptions(
urlTemplate:
Expand Down
11 changes: 5 additions & 6 deletions example/lib/pages/circle.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_example/widgets/drawer.dart';
import 'package:latlong2/latlong.dart';

import '../widgets/drawer.dart';

class CirclePage extends StatelessWidget {
static const String route = 'circle';

const CirclePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
var circleMarkers = <CircleMarker>[
final circleMarkers = <CircleMarker>[
CircleMarker(
point: LatLng(51.5, -0.09),
color: Colors.blue.withOpacity(0.7),
Expand All @@ -25,18 +24,18 @@ class CirclePage extends StatelessWidget {
appBar: AppBar(title: const Text('Circle')),
drawer: buildDrawer(context, route),
body: Padding(
padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8),
child: Column(
children: [
const Padding(
padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
padding: EdgeInsets.only(top: 8, bottom: 8),
child: Text('This is a map that is showing (51.5, -0.9).'),
),
Flexible(
child: FlutterMap(
options: MapOptions(
center: LatLng(51.5, -0.09),
zoom: 11.0,
zoom: 11,
),
layers: [
TileLayerOptions(
Expand Down
Loading

0 comments on commit 30ca5de

Please sign in to comment.