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

refactor: enable and fix some lint rules #452

Merged
merged 38 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d717f2f
avoid_escaping_inner_quotes
josxha Jun 6, 2024
855274a
Update analysis_options.yaml
josxha Jun 6, 2024
a38183e
prefer_if_elements_to_conditional_expressions
josxha Jun 6, 2024
c82d710
constant_identifier_names
josxha Jun 6, 2024
c0cf5dc
noop_primitive_operations
josxha Jun 6, 2024
bb3070f
avoid_bool_literals_in_conditional_expressions
josxha Jun 6, 2024
27eaca2
avoid_unused_constructor_parameters
josxha Jun 6, 2024
d37c0ed
no_default_cases
josxha Jun 6, 2024
c13a861
sort_pub_dependencies
josxha Jun 6, 2024
4dba61e
unnecessary_breaks
josxha Jun 6, 2024
cefcb25
avoid_redundant_argument_values
josxha Jun 6, 2024
ae8a5e0
avoid_setters_without_getters
josxha Jun 6, 2024
a5998ec
cast_nullable_to_non_nullable
josxha Jun 6, 2024
1a71596
only_throw_errors
josxha Jun 6, 2024
4da2620
no_runtimeType_toString
josxha Jun 6, 2024
bcf733b
prefer_constructors_over_static_methods
josxha Jun 6, 2024
ea66d0a
prefer_null_aware_method_calls
josxha Jun 6, 2024
86fe37e
unnecessary_await_in_return
josxha Jun 6, 2024
e99e99c
avoid_multiple_declarations_per_line
josxha Jun 6, 2024
638ebd8
unnecessary_string_escapes
josxha Jun 6, 2024
a9dfeac
combinators_ordering
josxha Jun 6, 2024
3eb7c37
avoid_equals_and_hash_code_on_mutable_classes
josxha Jun 6, 2024
69f0e14
unnecessary_library_directive
josxha Jun 6, 2024
00c1d3e
prefer_asserts_with_message
josxha Jun 6, 2024
d0c9dce
avoid_void_async
josxha Jun 6, 2024
5b3e4a9
prefer_final_fields
josxha Jun 6, 2024
21e8ca0
prefer_final_locals
josxha Jun 6, 2024
d016acd
prefer_final_in_for_each
josxha Jun 6, 2024
7873ae8
implicit_call_tearoffs
josxha Jun 6, 2024
f380893
avoid_type_to_string
josxha Jun 6, 2024
f9f971a
omit_local_variable_types
josxha Jun 6, 2024
cd3b990
use_named_constants
josxha Jun 6, 2024
a39ade9
dart format .
josxha Jun 6, 2024
244c852
Merge branch 'main' into refactor/lints
josxha Jun 24, 2024
e76778d
revert 00c1d3eac215adafa529942cd519c11131d9330b: prefer_asserts_with_…
josxha Jun 24, 2024
6ef2eef
revert 27eaca2447cbd704cf1110e6816b9ea8d472060e: avoid_unused_constru…
josxha Jun 24, 2024
7d0509a
fix bad revert
josxha Jun 24, 2024
f4018a4
Merge branch 'main' into refactor/lints
josxha Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,30 @@ analyzer:
linter:
rules:
# temporary rules
avoid_escaping_inner_quotes: false
prefer_interpolation_to_compose_strings: false
prefer_if_elements_to_conditional_expressions: false
constant_identifier_names: false
flutter_style_todos: false
one_member_abstracts: false
lines_longer_than_80_chars: false
prefer_int_literals: false
unnecessary_lambdas: false
avoid_print: false
noop_primitive_operations: false
avoid_bool_literals_in_conditional_expressions: false
avoid_unused_constructor_parameters: false
no_default_cases: false
sort_pub_dependencies: false
unnecessary_breaks: false
avoid_redundant_argument_values: false
unawaited_futures: false
overridden_fields: false
avoid_setters_without_getters: false
cast_nullable_to_non_nullable: false
only_throw_errors: false
no_runtimeType_toString: false
always_put_required_named_parameters_first: false
leading_newlines_in_multiline_strings: false
prefer_constructors_over_static_methods: false
prefer_null_aware_method_calls: false
directives_ordering: false
unnecessary_await_in_return: false
avoid_multiple_declarations_per_line: false
unnecessary_string_escapes: false
parameter_assignments: false
combinators_ordering: false
use_setters_to_change_properties: false
avoid_equals_and_hash_code_on_mutable_classes: false
type_annotate_public_apis: false
unnecessary_library_directive: false
prefer_asserts_with_message: false
public_member_api_docs: false
require_trailing_commas: false
avoid_dynamic_calls: false
avoid_void_async: false
always_use_package_imports: false
prefer_single_quotes: false
always_declare_return_types: false
sort_constructors_first: false
avoid_relative_lib_imports: false
avoid_positional_boolean_parameters: false
prefer_final_fields: false
prefer_final_locals: false
prefer_final_in_for_each: false
implicit_call_tearoffs: false
comment_references: false
cascade_invocations: false
avoid_type_to_string: false
omit_local_variable_types: false
use_named_constants: false
1 change: 1 addition & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ include: ../analysis_options.yaml
linter:
rules:
public_member_api_docs: false
avoid_redundant_argument_values: false
108 changes: 51 additions & 57 deletions example/lib/annotation_order_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,71 +31,65 @@ class _AnnotationOrderBodyState extends State<AnnotationOrderBody> {
return Column(
children: <Widget>[
Card(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 0.0),
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(bottom: 5.0),
child: Text(
'This map has polygones (fill) above all other anotations (default behavior)'),
),
Center(
child: SizedBox(
width: 250.0,
height: 250.0,
child: MapLibreMap(
onMapCreated: onMapCreatedOne,
onStyleLoadedCallback: () => onStyleLoaded(controllerOne),
initialCameraPosition: CameraPosition(
target: center,
zoom: 5.0,
),
annotationOrder: const [
AnnotationType.line,
AnnotationType.symbol,
AnnotationType.circle,
AnnotationType.fill,
],
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(bottom: 5.0),
child: Text(
'This map has polygones (fill) above all other anotations (default behavior)'),
),
Center(
child: SizedBox(
width: 250.0,
height: 250.0,
child: MapLibreMap(
onMapCreated: onMapCreatedOne,
onStyleLoadedCallback: () => onStyleLoaded(controllerOne),
initialCameraPosition: CameraPosition(
target: center,
zoom: 5.0,
),
annotationOrder: const [
AnnotationType.line,
AnnotationType.symbol,
AnnotationType.circle,
AnnotationType.fill,
],
),
),
],
),
),
],
),
),
Card(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 0.0),
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(bottom: 5.0, top: 5.0),
child: Text(
'This map has polygones (fill) under all other anotations'),
),
Center(
child: SizedBox(
width: 250.0,
height: 250.0,
child: MapLibreMap(
onMapCreated: onMapCreatedTwo,
onStyleLoadedCallback: () => onStyleLoaded(controllerTwo),
initialCameraPosition: CameraPosition(
target: center,
zoom: 5.0,
),
annotationOrder: const [
AnnotationType.fill,
AnnotationType.line,
AnnotationType.symbol,
AnnotationType.circle,
],
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(bottom: 5.0, top: 5.0),
child: Text(
'This map has polygones (fill) under all other anotations'),
),
Center(
child: SizedBox(
width: 250.0,
height: 250.0,
child: MapLibreMap(
onMapCreated: onMapCreatedTwo,
onStyleLoadedCallback: () => onStyleLoaded(controllerTwo),
initialCameraPosition: CameraPosition(
target: center,
zoom: 5.0,
),
annotationOrder: const [
AnnotationType.fill,
AnnotationType.line,
AnnotationType.symbol,
AnnotationType.circle,
],
),
),
],
),
),
],
),
),
],
Expand All @@ -110,7 +104,7 @@ class _AnnotationOrderBodyState extends State<AnnotationOrderBody> {
controllerTwo = controller;
}

void onStyleLoaded(MapLibreMapController controller) async {
Future<void> onStyleLoaded(MapLibreMapController controller) async {
await addImageFromAsset(
controller, "custom-marker", "assets/symbols/custom-marker.png");
controller.addSymbol(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/click_annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ClickAnnotationBodyState extends State<ClickAnnotationBody> {
_showSnackBar('symbol', symbol.id);
}

void _onStyleLoaded() async {
Future<void> _onStyleLoaded() async {
await addImageFromAsset(
controller!, "custom-marker", "assets/symbols/custom-marker.png");
controller!.addCircle(
Expand Down
12 changes: 6 additions & 6 deletions example/lib/custom_marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class CustomMarkerState extends State<CustomMarker> {
//_measurePerformance();

// Generate random markers
var param = <LatLng>[];
final param = <LatLng>[];
for (var i = 0; i < randomMarkerNum; i++) {
final lat = _rnd.nextDouble() * 20 + 30;
final lng = _rnd.nextDouble() * 20 + 125;
Expand All @@ -120,7 +120,7 @@ class CustomMarkerState extends State<CustomMarker> {

_mapController.toScreenLocationBatch(param).then((value) {
for (var i = 0; i < randomMarkerNum; i++) {
var point =
final point =
Point<double>(value[i].x as double, value[i].y as double);
_addMarker(point, param[i]);
}
Expand All @@ -141,17 +141,17 @@ class CustomMarkerState extends State<CustomMarker> {
}

_mapController.toScreenLocation(const LatLng(0, 0));
Stopwatch sw = Stopwatch();
final sw = Stopwatch();

for (final batch in batches) {
//
// primitive
//
for (var i = 0; i < trial; i++) {
sw.start();
var list = <Future<Point<num>>>[];
final list = <Future<Point<num>>>[];
for (var j = 0; j < batch; j++) {
var p = _mapController
final p = _mapController
.toScreenLocation(LatLng(j.toDouble() % 80, j.toDouble() % 300));
list.add(p);
}
Expand All @@ -166,7 +166,7 @@ class CustomMarkerState extends State<CustomMarker> {
//
for (var i = 0; i < trial; i++) {
sw.start();
var param = <LatLng>[];
final param = <LatLng>[];
for (var j = 0; j < batch; j++) {
param.add(LatLng(j.toDouble() % 80, j.toDouble() % 300));
}
Expand Down
8 changes: 4 additions & 4 deletions example/lib/get_map_informations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ class _GetMapInfoBodyState extends State<GetMapInfoBody> {
});
}

void displaySources() async {
Future<void> displaySources() async {
if (controller == null) {
return;
}
List<String> sources = await controller!.getSourceIds();
final sources = await controller!.getSourceIds();
setState(() {
data = 'Sources: ${sources.map((e) => '"$e"').join(', ')}';
});
}

void displayLayers() async {
Future<void> displayLayers() async {
if (controller == null) {
return;
}
List<String> layers = (await controller!.getLayerIds()).cast<String>();
final layers = (await controller!.getLayerIds()).cast<String>();
setState(() {
data = 'Layers: ${layers.map((e) => '"$e"').join(', ')}';
});
Expand Down
2 changes: 1 addition & 1 deletion example/lib/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class LayerState extends State {
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}

void _onStyleLoadedCallback() async {
Future<void> _onStyleLoadedCallback() async {
await addImageFromAsset(
controller, "custom-marker", "assets/symbols/custom-marker.png");
await controller.addGeoJsonSource("points", _points);
Expand Down
14 changes: 7 additions & 7 deletions example/lib/line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class LineBodyState extends State<LineBody> {

/// Adds an asset image to the currently displayed style
Future<void> addImageFromAsset(String name, String assetName) async {
final ByteData bytes = await rootBundle.load(assetName);
final Uint8List list = bytes.buffer.asUint8List();
final bytes = await rootBundle.load(assetName);
final list = bytes.buffer.asUint8List();
return controller!.addImage(name, list);
}

Expand Down Expand Up @@ -109,15 +109,15 @@ class LineBodyState extends State<LineBody> {
}

Future<void> _changeLinePattern() async {
String? current =
final current =
_selectedLine!.options.linePattern == null ? "assetImage" : null;
await _updateSelectedLine(
LineOptions(linePattern: current),
);
}

Future<void> _changeAlpha() async {
double? current = _selectedLine!.options.lineOpacity;
var current = _selectedLine!.options.lineOpacity;
current ??= 1.0;

await _updateSelectedLine(
Expand All @@ -126,7 +126,7 @@ class LineBodyState extends State<LineBody> {
}

Future<void> _toggleVisible() async {
double? current = _selectedLine!.options.lineOpacity;
var current = _selectedLine!.options.lineOpacity;
current ??= 1.0;
await _updateSelectedLine(
LineOptions(lineOpacity: current == 0.0 ? 1.0 : 0.0),
Expand Down Expand Up @@ -213,9 +213,9 @@ class LineBodyState extends State<LineBody> {
onPressed: (_selectedLine == null)
? null
: () async {
var latLngs = await controller!
final latLngs = await controller!
.getLineLatLngs(_selectedLine!);
for (var latLng in latLngs) {
for (final latLng in latLngs) {
debugPrint(latLng.toString());
}
},
Expand Down
8 changes: 4 additions & 4 deletions example/lib/local_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class LocalStyleState extends State<LocalStyle> {
super.initState();

getApplicationDocumentsDirectory().then((dir) async {
String documentDir = dir.path;
String stylesDir = '$documentDir/styles';
String styleJSON =
final documentDir = dir.path;
final stylesDir = '$documentDir/styles';
const styleJSON =
'{"version":8,"name":"Demo style","center":[50,10],"zoom":4,"sources":{"demotiles":{"type":"vector","url":"https://demotiles.maplibre.org/tiles/tiles.json"}},"sprite":"","glyphs":"https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"rgba(255, 255, 255, 1)"}},{"id":"countries","type":"line","source":"demotiles","source-layer":"countries","paint":{"line-color":"rgba(0, 0, 0, 1)","line-width":1,"line-opacity":1}}]}';

await Directory(stylesDir).create(recursive: true);

File styleFile = File('$stylesDir/style.json');
final styleFile = File('$stylesDir/style.json');

await styleFile.writeAsString(styleJSON);

Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _MapsDemoState extends State<MapsDemo> {
}
}

void _pushPage(BuildContext context, ExamplePage page) async {
Future<void> _pushPage(BuildContext context, ExamplePage page) async {
if (!kIsWeb && page.needsLocationPermission) {
final location = Location();
final hasPermissions = await location.hasPermission();
Expand Down
Loading