Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2.2.0] Stricten Lints & Fix Tests Exceptions #1319

Merged
merged 10 commits into from
Aug 2, 2022
9 changes: 5 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
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
JaffaKetchup marked this conversation as resolved.
Show resolved Hide resolved
missing_required_param: error
Expand All @@ -17,4 +18,4 @@ linter:
always_use_package_imports: true
type_annotate_public_apis: true
prefer_int_literals: true
use_named_constants: true
use_named_constants: true
18 changes: 18 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
include: package:flutter_lints/flutter.yaml

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

linter:
rules:
library_private_types_in_public_api: false
prefer_final_locals: true
prefer_final_in_for_each: true
avoid_dynamic_calls: true
always_use_package_imports: true
type_annotate_public_apis: true
prefer_int_literals: 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
19 changes: 9 additions & 10 deletions example/lib/pages/custom_crs/custom_crs.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map_example/widgets/drawer.dart';
import 'package:latlong2/latlong.dart';
import 'package:proj4dart/proj4dart.dart' as proj4;

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

class CustomCrsPage extends StatefulWidget {
static const String route = 'custom_crs';

Expand Down Expand Up @@ -93,34 +92,34 @@ class _CustomCrsPageState extends State<CustomCrsPage> {
appBar: AppBar(title: const Text('Custom CRS')),
drawer: buildDrawer(context, CustomCrsPage.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: 2.0),
padding: EdgeInsets.only(top: 8, bottom: 2),
child: Text(
'This map is in EPSG:3413',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.blue,
fontSize: 16.0,
fontSize: 16,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 2.0),
padding: const EdgeInsets.only(top: 8, bottom: 2),
child: Text(
'$initText (${point.x.toStringAsFixed(5)}, ${point.y.toStringAsFixed(5)}) in EPSG:4326.',
),
),
Padding(
padding: const EdgeInsets.only(top: 2.0, bottom: 2.0),
padding: const EdgeInsets.only(top: 2, bottom: 2),
child: Text(
'Which is (${epsg4326.transform(epsg3413, point).x.toStringAsFixed(2)}, ${epsg4326.transform(epsg3413, point).y.toStringAsFixed(2)}) in EPSG:3413.',
),
),
const Padding(
padding: EdgeInsets.only(top: 2.0, bottom: 8.0),
padding: EdgeInsets.only(top: 2, bottom: 8),
child: Text('Tap on map to get more coordinates!'),
),
Flexible(
Expand All @@ -129,7 +128,7 @@ class _CustomCrsPageState extends State<CustomCrsPage> {
// Set the default CRS
crs: epsg3413CRS,
center: LatLng(point.x, point.y),
zoom: 3.0,
zoom: 3,
// Set maxZoom usually scales.length - 1 OR resolutions.length - 1
// but not greater
maxZoom: maxZoom,
Expand All @@ -140,7 +139,7 @@ class _CustomCrsPageState extends State<CustomCrsPage> {
),
layers: [
TileLayerOptions(
opacity: 1.0,
opacity: 1,
backgroundColor: Colors.transparent,
wmsOptions: WMSTileLayerOptions(
// Set the WMS layer's CRS
Expand Down
Loading