diff --git a/analysis_options.yaml b/analysis_options.yaml index 202093b55..3a15130c2 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,48 +1,21 @@ -include: package:pedantic/analysis_options.yaml +include: package:flutter_lints/flutter.yaml linter: rules: - always_declare_return_types - - annotate_overrides - - avoid_function_literals_in_foreach_calls - - avoid_null_checks_in_equality_operators - avoid_returning_null - avoid_unused_constructor_parameters - - await_only_futures - - camel_case_types - cancel_subscriptions - comment_references - - constant_identifier_names - - control_flow_in_finally - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - invariant_booleans - - iterable_contains_unrelated_type - - list_remove_unrelated_type - no_adjacent_strings_in_list - - non_constant_identifier_names - omit_local_variable_types - only_throw_errors - - overridden_fields - - package_names - - package_prefixed_library_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - - prefer_final_fields - - prefer_initializing_formals - prefer_interpolation_to_compose_strings - - prefer_null_aware_operators - prefer_single_quotes - - prefer_typing_uninitialized_variables - sort_pub_dependencies - test_types_in_equals - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - unnecessary_lambdas - - unnecessary_new - unnecessary_null_aware_assignments - unnecessary_statements - - unnecessary_this diff --git a/example/lib/main.dart b/example/lib/main.dart index c07210957..40945013b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -33,9 +33,11 @@ import './pages/tile_loading_error_handle.dart'; import './pages/widgets.dart'; import './pages/wms_tile_layer.dart'; -void main() => runApp(MyApp()); +void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + // This widget is the root of your application. @override Widget build(BuildContext context) { @@ -44,40 +46,42 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: mapBoxBlue, ), - home: HomePage(), + home: const HomePage(), routes: { - NetworkTileProviderPage.route: (context) => NetworkTileProviderPage(), - WidgetsPage.route: (context) => WidgetsPage(), - TapToAddPage.route: (context) => TapToAddPage(), - EsriPage.route: (context) => EsriPage(), - PolylinePage.route: (context) => PolylinePage(), - MapControllerPage.route: (context) => MapControllerPage(), + NetworkTileProviderPage.route: (context) => + const NetworkTileProviderPage(), + WidgetsPage.route: (context) => const WidgetsPage(), + TapToAddPage.route: (context) => const TapToAddPage(), + EsriPage.route: (context) => const EsriPage(), + PolylinePage.route: (context) => const PolylinePage(), + MapControllerPage.route: (context) => const MapControllerPage(), AnimatedMapControllerPage.route: (context) => - AnimatedMapControllerPage(), - MarkerAnchorPage.route: (context) => MarkerAnchorPage(), - PluginPage.route: (context) => PluginPage(), - PluginScaleBar.route: (context) => PluginScaleBar(), - PluginZoomButtons.route: (context) => PluginZoomButtons(), - OfflineMapPage.route: (context) => OfflineMapPage(), - OnTapPage.route: (context) => OnTapPage(), - MarkerRotatePage.route: (context) => MarkerRotatePage(), - MovingMarkersPage.route: (context) => MovingMarkersPage(), - CirclePage.route: (context) => CirclePage(), - OverlayImagePage.route: (context) => OverlayImagePage(), - PolygonPage.route: (context) => PolygonPage(), - SlidingMapPage.route: (_) => SlidingMapPage(), - WMSLayerPage.route: (context) => WMSLayerPage(), - CustomCrsPage.route: (context) => CustomCrsPage(), - LiveLocationPage.route: (context) => LiveLocationPage(), - TileLoadingErrorHandle.route: (context) => TileLoadingErrorHandle(), - TileBuilderPage.route: (context) => TileBuilderPage(), - InteractiveTestPage.route: (context) => InteractiveTestPage(), - ManyMarkersPage.route: (context) => ManyMarkersPage(), - StatefulMarkersPage.route: (context) => StatefulMarkersPage(), - MapInsideListViewPage.route: (context) => MapInsideListViewPage(), - ResetTileLayerPage.route: (context) => ResetTileLayerPage(), - EPSG4326Page.route: (context) => EPSG4326Page(), - MaxBoundsPage.route: (context) => MaxBoundsPage(), + const AnimatedMapControllerPage(), + MarkerAnchorPage.route: (context) => const MarkerAnchorPage(), + PluginPage.route: (context) => const PluginPage(), + PluginScaleBar.route: (context) => const PluginScaleBar(), + PluginZoomButtons.route: (context) => const PluginZoomButtons(), + OfflineMapPage.route: (context) => const OfflineMapPage(), + OnTapPage.route: (context) => const OnTapPage(), + MarkerRotatePage.route: (context) => const MarkerRotatePage(), + MovingMarkersPage.route: (context) => const MovingMarkersPage(), + CirclePage.route: (context) => const CirclePage(), + OverlayImagePage.route: (context) => const OverlayImagePage(), + PolygonPage.route: (context) => const PolygonPage(), + SlidingMapPage.route: (_) => const SlidingMapPage(), + WMSLayerPage.route: (context) => const WMSLayerPage(), + CustomCrsPage.route: (context) => const CustomCrsPage(), + LiveLocationPage.route: (context) => const LiveLocationPage(), + TileLoadingErrorHandle.route: (context) => + const TileLoadingErrorHandle(), + TileBuilderPage.route: (context) => const TileBuilderPage(), + InteractiveTestPage.route: (context) => const InteractiveTestPage(), + ManyMarkersPage.route: (context) => const ManyMarkersPage(), + StatefulMarkersPage.route: (context) => const StatefulMarkersPage(), + MapInsideListViewPage.route: (context) => const MapInsideListViewPage(), + ResetTileLayerPage.route: (context) => const ResetTileLayerPage(), + EPSG4326Page.route: (context) => const EPSG4326Page(), + MaxBoundsPage.route: (context) => const MaxBoundsPage(), }, ); } diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index 892403f4e..25a17ddb7 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class AnimatedMapControllerPage extends StatefulWidget { static const String route = 'map_controller_animated'; + const AnimatedMapControllerPage({Key? key}) : super(key: key); + @override AnimatedMapControllerPageState createState() { return AnimatedMapControllerPageState(); @@ -79,19 +81,17 @@ class AnimatedMapControllerPageState extends State height: 80.0, point: london, builder: (ctx) => Container( - key: Key('blue'), - child: FlutterLogo(), + key: const Key('blue'), + child: const FlutterLogo(), ), ), Marker( width: 80.0, height: 80.0, point: dublin, - builder: (ctx) => Container( - child: FlutterLogo( - key: Key('green'), - textColor: Colors.green, - ), + builder: (ctx) => const FlutterLogo( + key: Key('green'), + textColor: Colors.green, ), ), Marker( @@ -99,46 +99,46 @@ class AnimatedMapControllerPageState extends State height: 80.0, point: paris, builder: (ctx) => Container( - key: Key('purple'), - child: FlutterLogo(textColor: Colors.purple), + key: const Key('purple'), + child: const FlutterLogo(textColor: Colors.purple), ), ), ]; return Scaffold( - appBar: AppBar(title: Text('Animated MapController')), + appBar: AppBar(title: const Text('Animated MapController')), drawer: buildDrawer(context, AnimatedMapControllerPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Row( children: [ MaterialButton( onPressed: () { _animatedMapMove(london, 10.0); }, - child: Text('London'), + child: const Text('London'), ), MaterialButton( onPressed: () { _animatedMapMove(paris, 5.0); }, - child: Text('Paris'), + child: const Text('Paris'), ), MaterialButton( onPressed: () { _animatedMapMove(dublin, 5.0); }, - child: Text('Dublin'), + child: const Text('Dublin'), ), ], ), ), Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Row( children: [ MaterialButton( @@ -149,12 +149,12 @@ class AnimatedMapControllerPageState extends State bounds.extend(london); mapController.fitBounds( bounds, - options: FitBoundsOptions( + options: const FitBoundsOptions( padding: EdgeInsets.only(left: 15.0, right: 15.0), ), ); }, - child: Text('Fit Bounds'), + child: const Text('Fit Bounds'), ), MaterialButton( onPressed: () { @@ -167,7 +167,7 @@ class AnimatedMapControllerPageState extends State mapController.centerZoomFitBounds(bounds); _animatedMapMove(centerZoom.center, centerZoom.zoom); }, - child: Text('Fit Bounds animated'), + child: const Text('Fit Bounds animated'), ), ], ), diff --git a/example/lib/pages/circle.dart b/example/lib/pages/circle.dart index 01eb386c7..0d2e98189 100644 --- a/example/lib/pages/circle.dart +++ b/example/lib/pages/circle.dart @@ -7,6 +7,8 @@ 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 = [ @@ -20,13 +22,13 @@ class CirclePage extends StatelessWidget { ]; return Scaffold( - appBar: AppBar(title: Text('Circle')), + appBar: AppBar(title: const Text('Circle')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('This is a map that is showing (51.5, -0.9).'), ), diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index 76093531b..165a292f9 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -8,6 +8,8 @@ import '../../widgets/drawer.dart'; class CustomCrsPage extends StatefulWidget { static const String route = 'custom_crs'; + const CustomCrsPage({Key? key}) : super(key: key); + @override _CustomCrsPageState createState() => _CustomCrsPageState(); } @@ -54,8 +56,8 @@ class _CustomCrsPageState extends State { ]; final epsg3413Bounds = Bounds( - CustomPoint(-4511619.0, -4511336.0), - CustomPoint(4510883.0, 4510996.0), + const CustomPoint(-4511619.0, -4511336.0), + const CustomPoint(4510883.0, 4510996.0), ); maxZoom = (resolutions.length - 1).toDouble(); @@ -76,7 +78,7 @@ class _CustomCrsPageState extends State { // Some goeserver changes origin based on zoom level // and some are not at all (use explicit/implicit null or use [CustomPoint(0, 0)]) // @see https://github.com/kartena/Proj4Leaflet/pull/171 - origins: [CustomPoint(0, 0)], + origins: [const CustomPoint(0, 0)], // Scale factors (pixels per projection unit, for example pixels/meter) for zoom levels; // specify either scales or resolutions, not both scales: null, @@ -88,13 +90,13 @@ class _CustomCrsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Custom CRS')), + appBar: AppBar(title: const Text('Custom CRS')), drawer: buildDrawer(context, CustomCrsPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 2.0), child: Text( 'This map is in EPSG:3413', @@ -106,18 +108,18 @@ class _CustomCrsPageState extends State { ), ), Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 2.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 2.0), child: Text( '$initText (${point.x.toStringAsFixed(5)}, ${point.y.toStringAsFixed(5)}) in EPSG:4326.', ), ), Padding( - padding: EdgeInsets.only(top: 2.0, bottom: 2.0), + padding: const EdgeInsets.only(top: 2.0, bottom: 2.0), child: Text( 'Which is (${epsg4326.transform(epsg3413, point).x.toStringAsFixed(2)}, ${epsg4326.transform(epsg3413, point).y.toStringAsFixed(2)}) in EPSG:3413.', ), ), - Padding( + const Padding( padding: EdgeInsets.only(top: 2.0, bottom: 8.0), child: Text('Tap on map to get more coordinates!'), ), diff --git a/example/lib/pages/epsg4326_crs.dart b/example/lib/pages/epsg4326_crs.dart index 2c586502d..1a0c0e9cb 100644 --- a/example/lib/pages/epsg4326_crs.dart +++ b/example/lib/pages/epsg4326_crs.dart @@ -7,16 +7,18 @@ import '../widgets/drawer.dart'; class EPSG4326Page extends StatelessWidget { static const String route = 'EPSG4326 Page'; + const EPSG4326Page({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('EPSG4326')), + appBar: AppBar(title: const Text('EPSG4326')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('This is a map that is showing (42.58, 12.43).'), ), diff --git a/example/lib/pages/esri.dart b/example/lib/pages/esri.dart index 7976e133e..845332f96 100644 --- a/example/lib/pages/esri.dart +++ b/example/lib/pages/esri.dart @@ -7,16 +7,18 @@ import '../widgets/drawer.dart'; class EsriPage extends StatelessWidget { static const String route = 'esri'; + const EsriPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Esri')), + appBar: AppBar(title: const Text('Esri')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('Esri'), ), diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart index 9e4146ed3..bc118923e 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class HomePage extends StatelessWidget { static const String route = '/'; + const HomePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var markers = [ @@ -14,45 +16,39 @@ class HomePage extends StatelessWidget { width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.blue, - key: ObjectKey(Colors.blue), - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.blue, + key: ObjectKey(Colors.blue), ), ), Marker( width: 80.0, height: 80.0, point: LatLng(53.3498, -6.2603), - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.green, - key: ObjectKey(Colors.green), - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.green, + key: ObjectKey(Colors.green), ), ), Marker( width: 80.0, height: 80.0, point: LatLng(48.8566, 2.3522), - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.purple, - key: ObjectKey(Colors.purple), - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.purple, + key: ObjectKey(Colors.purple), ), ), ]; return Scaffold( - appBar: AppBar(title: Text('Home')), + appBar: AppBar(title: const Text('Home')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('This is a map that is showing (51.5, -0.9).'), ), @@ -70,7 +66,7 @@ class HomePage extends StatelessWidget { // For example purposes. It is recommended to use // TileProvider with a caching and retry strategy, like // NetworkTileProvider or CachedNetworkTileProvider - tileProvider: NonCachingNetworkTileProvider(), + tileProvider: const NonCachingNetworkTileProvider(), ), MarkerLayerOptions(markers: markers) ], diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index 40fdc50e4..b853148ec 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -9,6 +9,8 @@ import '../widgets/drawer.dart'; class InteractiveTestPage extends StatefulWidget { static const String route = 'interactive_test_page'; + const InteractiveTestPage({Key? key}) : super(key: key); + @override State createState() { return _InteractiveTestPageState(); @@ -41,7 +43,7 @@ class _InteractiveTestPageState extends State { void onMapEvent(MapEvent mapEvent) { if (mapEvent is! MapEventMove && mapEvent is! MapEventRotate) { // do not flood console with move and rotate events - print(mapEvent); + debugPrint(mapEvent.toString()); } } @@ -58,10 +60,10 @@ class _InteractiveTestPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Test out Interactive flags!')), + appBar: AppBar(title: const Text('Test out Interactive flags!')), drawer: buildDrawer(context, InteractiveTestPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Row( @@ -76,7 +78,7 @@ class _InteractiveTestPageState extends State { updateFlags(InteractiveFlag.drag); }); }, - child: Text('Drag'), + child: const Text('Drag'), ), MaterialButton( color: InteractiveFlag.hasFlag( @@ -88,7 +90,7 @@ class _InteractiveTestPageState extends State { updateFlags(InteractiveFlag.flingAnimation); }); }, - child: Text('Fling'), + child: const Text('Fling'), ), MaterialButton( color: @@ -100,7 +102,7 @@ class _InteractiveTestPageState extends State { updateFlags(InteractiveFlag.pinchMove); }); }, - child: Text('Pinch move'), + child: const Text('Pinch move'), ), ], ), @@ -117,7 +119,7 @@ class _InteractiveTestPageState extends State { updateFlags(InteractiveFlag.doubleTapZoom); }); }, - child: Text('Double tap zoom'), + child: const Text('Double tap zoom'), ), MaterialButton( color: InteractiveFlag.hasFlag(flags, InteractiveFlag.rotate) @@ -128,7 +130,7 @@ class _InteractiveTestPageState extends State { updateFlags(InteractiveFlag.rotate); }); }, - child: Text('Rotate'), + child: const Text('Rotate'), ), MaterialButton( color: @@ -140,19 +142,19 @@ class _InteractiveTestPageState extends State { updateFlags(InteractiveFlag.pinchZoom); }); }, - child: Text('Pinch zoom'), + child: const Text('Pinch zoom'), ), ], ), Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Center( child: StreamBuilder( stream: mapController.mapEventStream, builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { - return Text( + return const Text( 'Current event: none\nSource: none', textAlign: TextAlign.center, ); diff --git a/example/lib/pages/live_location.dart b/example/lib/pages/live_location.dart index 4d2f4e34e..ddf5b3e58 100644 --- a/example/lib/pages/live_location.dart +++ b/example/lib/pages/live_location.dart @@ -9,6 +9,8 @@ import '../widgets/drawer.dart'; class LiveLocationPage extends StatefulWidget { static const String route = '/live_location'; + const LiveLocationPage({Key? key}) : super(key: key); + @override _LiveLocationPageState createState() => _LiveLocationPageState(); } @@ -78,7 +80,7 @@ class _LiveLocationPageState extends State { } } } on PlatformException catch (e) { - print(e); + debugPrint(e.toString()); if (e.code == 'PERMISSION_DENIED') { _serviceError = e.message; } else if (e.code == 'SERVICE_STATUS_ERROR') { @@ -106,24 +108,22 @@ class _LiveLocationPageState extends State { width: 80.0, height: 80.0, point: currentLatLng, - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.blue, - key: ObjectKey(Colors.blue), - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.blue, + key: ObjectKey(Colors.blue), ), ), ]; return Scaffold( - appBar: AppBar(title: Text('Home')), + appBar: AppBar(title: const Text('Home')), drawer: buildDrawer(context, LiveLocationPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: _serviceError!.isEmpty ? Text('This is a map that is showing ' '(${currentLatLng.latitude}, ${currentLatLng.longitude}).') @@ -148,7 +148,7 @@ class _LiveLocationPageState extends State { // For example purposes. It is recommended to use // TileProvider with a caching and retry strategy, like // NetworkTileProvider or CachedNetworkTileProvider - tileProvider: NonCachingNetworkTileProvider(), + tileProvider: const NonCachingNetworkTileProvider(), ), MarkerLayerOptions(markers: markers) ], @@ -168,7 +168,7 @@ class _LiveLocationPageState extends State { InteractiveFlag.pinchZoom | InteractiveFlag.doubleTapZoom; - ScaffoldMessenger.of(context).showSnackBar(SnackBar( + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( content: Text( 'In live update mode only zoom and rotation are enable'), )); @@ -177,8 +177,9 @@ class _LiveLocationPageState extends State { } }); }, - child: - _liveUpdate ? Icon(Icons.location_on) : Icon(Icons.location_off), + child: _liveUpdate + ? const Icon(Icons.location_on) + : const Icon(Icons.location_off), ); }), ); diff --git a/example/lib/pages/many_markers.dart b/example/lib/pages/many_markers.dart index 0b1fc4fd5..d76fda483 100644 --- a/example/lib/pages/many_markers.dart +++ b/example/lib/pages/many_markers.dart @@ -15,6 +15,8 @@ const maxMarkersCount = 5000; class ManyMarkersPage extends StatefulWidget { static const String route = '/many_markers'; + const ManyMarkersPage({Key? key}) : super(key: key); + @override _ManyMarkersPageState createState() => _ManyMarkersPageState(); } @@ -53,7 +55,7 @@ class _ManyMarkersPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('A lot of markers')), + appBar: AppBar(title: const Text('A lot of markers')), drawer: buildDrawer(context, ManyMarkersPage.route), body: Column( children: [ diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index ec3e4658e..6df32c2b7 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -10,6 +10,8 @@ import '../widgets/drawer.dart'; class MapControllerPage extends StatefulWidget { static const String route = 'map_controller'; + const MapControllerPage({Key? key}) : super(key: key); + @override MapControllerPageState createState() { return MapControllerPageState(); @@ -38,19 +40,17 @@ class MapControllerPageState extends State { height: 80.0, point: london, builder: (ctx) => Container( - key: Key('blue'), - child: FlutterLogo(), + key: const Key('blue'), + child: const FlutterLogo(), ), ), Marker( width: 80.0, height: 80.0, point: dublin, - builder: (ctx) => Container( - child: FlutterLogo( - key: Key('green'), - textColor: Colors.green, - ), + builder: (ctx) => const FlutterLogo( + key: Key('green'), + textColor: Colors.green, ), ), Marker( @@ -58,47 +58,47 @@ class MapControllerPageState extends State { height: 80.0, point: paris, builder: (ctx) => Container( - key: Key('purple'), - child: FlutterLogo(textColor: Colors.purple), + key: const Key('purple'), + child: const FlutterLogo(textColor: Colors.purple), ), ), ]; return Scaffold( - appBar: AppBar(title: Text('MapController')), + appBar: AppBar(title: const Text('MapController')), drawer: buildDrawer(context, MapControllerPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Row( children: [ MaterialButton( onPressed: () { mapController.move(london, 18.0); }, - child: Text('London'), + child: const Text('London'), ), MaterialButton( onPressed: () { mapController.move(paris, 5.0); }, - child: Text('Paris'), + child: const Text('Paris'), ), MaterialButton( onPressed: () { mapController.move(dublin, 5.0); }, - child: Text('Dublin'), + child: const Text('Dublin'), ), CurrentLocation(mapController: mapController), ], ), ), Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Row( children: [ MaterialButton( @@ -109,12 +109,12 @@ class MapControllerPageState extends State { bounds.extend(london); mapController.fitBounds( bounds, - options: FitBoundsOptions( + options: const FitBoundsOptions( padding: EdgeInsets.only(left: 15.0, right: 15.0), ), ); }, - child: Text('Fit Bounds'), + child: const Text('Fit Bounds'), ), Builder(builder: (BuildContext context) { return MaterialButton( @@ -131,10 +131,10 @@ class MapControllerPageState extends State { ), )); }, - child: Text('Get Bounds'), + child: const Text('Get Bounds'), ); }), - Text('Rotation:'), + const Text('Rotation:'), Expanded( child: Slider( value: rotation, diff --git a/example/lib/pages/map_inside_listview.dart b/example/lib/pages/map_inside_listview.dart index 968351d26..da1e2a6da 100644 --- a/example/lib/pages/map_inside_listview.dart +++ b/example/lib/pages/map_inside_listview.dart @@ -8,17 +8,19 @@ import '../widgets/drawer.dart'; class MapInsideListViewPage extends StatelessWidget { static const String route = 'map_inside_listview'; + const MapInsideListViewPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Map inside ListView')), + appBar: AppBar(title: const Text('Map inside ListView')), drawer: buildDrawer(context, MapInsideListViewPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: ListView( scrollDirection: Axis.vertical, children: [ - Container( + SizedBox( height: 300, child: FlutterMap( options: MapOptions( @@ -48,13 +50,13 @@ class MapInsideListViewPage extends StatelessWidget { ], ), ), - Card( + const Card( child: ListTile( title: Text( 'Scrolling inside the map does not scroll the ListView')), ), - SizedBox(height: 500), - Card(child: ListTile(title: Text('look at that scrolling'))) + const SizedBox(height: 500), + const Card(child: ListTile(title: Text('look at that scrolling'))) ], ), ), diff --git a/example/lib/pages/marker_anchor.dart b/example/lib/pages/marker_anchor.dart index 8f5c4e482..68c4ea32c 100644 --- a/example/lib/pages/marker_anchor.dart +++ b/example/lib/pages/marker_anchor.dart @@ -6,6 +6,9 @@ import '../widgets/drawer.dart'; class MarkerAnchorPage extends StatefulWidget { static const String route = '/marker_anchors'; + + const MarkerAnchorPage({Key? key}) : super(key: key); + @override MarkerAnchorPageState createState() { return MarkerAnchorPageState(); @@ -40,19 +43,15 @@ class MarkerAnchorPageState extends State { width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), anchorPos: anchorPos, ), Marker( width: 80.0, height: 80.0, point: LatLng(53.3498, -6.2603), - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.green, - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.green, ), anchorPos: anchorPos, ), @@ -60,52 +59,50 @@ class MarkerAnchorPageState extends State { width: 80.0, height: 80.0, point: LatLng(48.8566, 2.3522), - builder: (ctx) => Container( - child: FlutterLogo(textColor: Colors.purple), - ), + builder: (ctx) => const FlutterLogo(textColor: Colors.purple), anchorPos: anchorPos, ), ]; return Scaffold( - appBar: AppBar(title: Text('Marker Anchor Points')), + appBar: AppBar(title: const Text('Marker Anchor Points')), drawer: buildDrawer(context, MarkerAnchorPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text( 'Markers can be anchored to the top, bottom, left or right.'), ), Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Wrap( children: [ MaterialButton( onPressed: () => _setAnchorAlignPos(AnchorAlign.left), - child: Text('Left'), + child: const Text('Left'), ), MaterialButton( onPressed: () => _setAnchorAlignPos(AnchorAlign.right), - child: Text('Right'), + child: const Text('Right'), ), MaterialButton( onPressed: () => _setAnchorAlignPos(AnchorAlign.top), - child: Text('Top'), + child: const Text('Top'), ), MaterialButton( onPressed: () => _setAnchorAlignPos(AnchorAlign.bottom), - child: Text('Bottom'), + child: const Text('Bottom'), ), MaterialButton( onPressed: () => _setAnchorAlignPos(AnchorAlign.center), - child: Text('Center'), + child: const Text('Center'), ), MaterialButton( onPressed: () => _setAnchorExactlyPos(Anchor(80.0, 80.0)), - child: Text('Custom'), + child: const Text('Custom'), ), ], ), diff --git a/example/lib/pages/marker_rotate.dart b/example/lib/pages/marker_rotate.dart index a63ba2bef..dd9c43006 100644 --- a/example/lib/pages/marker_rotate.dart +++ b/example/lib/pages/marker_rotate.dart @@ -6,6 +6,9 @@ import '../widgets/drawer.dart'; class MarkerRotatePage extends StatefulWidget { static const String route = '/marker_rotate'; + + const MarkerRotatePage({Key? key}) : super(key: key); + @override MarkerRotatePageState createState() { return MarkerRotatePageState(); @@ -73,19 +76,15 @@ class MarkerRotatePageState extends State { height: 80.0, point: LatLng(51.5, -0.09), rotate: rotateMarkerLondon, - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), Marker( width: 80.0, height: 80.0, point: LatLng(53.3498, -6.2603), rotate: rotateMarkerDublin, - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.green, - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.green, ), ), Marker( @@ -93,26 +92,24 @@ class MarkerRotatePageState extends State { height: 80.0, point: LatLng(48.8566, 2.3522), rotate: rotateMarkerParis, - builder: (ctx) => Container( - child: FlutterLogo(textColor: Colors.purple), - ), + builder: (ctx) => const FlutterLogo(textColor: Colors.purple), ), ]; return Scaffold( - appBar: AppBar(title: Text('Marker rotate by Map')), + appBar: AppBar(title: const Text('Marker rotate by Map')), drawer: buildDrawer(context, MarkerRotatePage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('Markers can be counter rotated to the map rotation.'), ), Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Wrap( children: [ MaterialButton( diff --git a/example/lib/pages/max_bounds.dart b/example/lib/pages/max_bounds.dart index cacf9fe81..feb526ea6 100644 --- a/example/lib/pages/max_bounds.dart +++ b/example/lib/pages/max_bounds.dart @@ -7,16 +7,18 @@ import '../widgets/drawer.dart'; class MaxBoundsPage extends StatelessWidget { static const String route = '/max_bounds'; + const MaxBoundsPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Max Bounds edges check')), + appBar: AppBar(title: const Text('Max Bounds edges check')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text( 'This is a map that has edges constrained to a latlng bounds.'), diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index 7d015a288..a33327463 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -9,6 +9,8 @@ import '../widgets/drawer.dart'; class MovingMarkersPage extends StatefulWidget { static const String route = '/moving_markers'; + const MovingMarkersPage({Key? key}) : super(key: key); + @override _MovingMarkersPageState createState() { return _MovingMarkersPageState(); @@ -24,7 +26,7 @@ class _MovingMarkersPageState extends State { void initState() { super.initState(); _marker = _markers[_markerIndex]; - _timer = Timer.periodic(Duration(seconds: 1), (_) { + _timer = Timer.periodic(const Duration(seconds: 1), (_) { setState(() { _marker = _markers[_markerIndex]; _markerIndex = (_markerIndex + 1) % _markers.length; @@ -41,13 +43,13 @@ class _MovingMarkersPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Home')), + appBar: AppBar(title: const Text('Home')), drawer: buildDrawer(context, MovingMarkersPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('This is a map that is showing (51.5, -0.9).'), ), @@ -78,24 +80,18 @@ List _markers = [ width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), Marker( width: 80.0, height: 80.0, point: LatLng(53.3498, -6.2603), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), Marker( width: 80.0, height: 80.0, point: LatLng(48.8566, 2.3522), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), ]; diff --git a/example/lib/pages/network_tile_provider.dart b/example/lib/pages/network_tile_provider.dart index b93c6a858..2d7635992 100644 --- a/example/lib/pages/network_tile_provider.dart +++ b/example/lib/pages/network_tile_provider.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class NetworkTileProviderPage extends StatelessWidget { static const String route = 'NetworkTileProvider'; + const NetworkTileProviderPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var markers = [ @@ -14,47 +16,41 @@ class NetworkTileProviderPage extends StatelessWidget { width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.blue, - key: ObjectKey(Colors.blue), - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.blue, + key: ObjectKey(Colors.blue), ), ), Marker( width: 80.0, height: 80.0, point: LatLng(53.3498, -6.2603), - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.green, - key: ObjectKey(Colors.green), - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.green, + key: ObjectKey(Colors.green), ), ), Marker( width: 80.0, height: 80.0, point: LatLng(48.8566, 2.3522), - builder: (ctx) => Container( - child: FlutterLogo( - textColor: Colors.purple, - key: ObjectKey(Colors.purple), - ), + builder: (ctx) => const FlutterLogo( + textColor: Colors.purple, + key: ObjectKey(Colors.purple), ), ), ]; return Scaffold( - appBar: AppBar(title: Text('NetworkTileProvider')), + appBar: AppBar(title: const Text('NetworkTileProvider')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), - child: Wrap(children: [ + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + child: Wrap(children: const [ Text('This Provider does not provide caching.'), Text( 'For further options about that, check flutter_map\'s README on GitHub.'), diff --git a/example/lib/pages/offline_map.dart b/example/lib/pages/offline_map.dart index 868bde97d..1f796f090 100644 --- a/example/lib/pages/offline_map.dart +++ b/example/lib/pages/offline_map.dart @@ -7,16 +7,18 @@ import '../widgets/drawer.dart'; class OfflineMapPage extends StatelessWidget { static const String route = '/offline_map'; + const OfflineMapPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Offline Map')), + appBar: AppBar(title: const Text('Offline Map')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text( 'This is an offline map that is showing Anholt Island, Denmark.'), @@ -33,7 +35,7 @@ class OfflineMapPage extends StatelessWidget { ), layers: [ TileLayerOptions( - tileProvider: AssetTileProvider(), + tileProvider: const AssetTileProvider(), maxZoom: 14.0, urlTemplate: 'assets/map/anholt_osmbright/{z}/{x}/{y}.png', ), diff --git a/example/lib/pages/on_tap.dart b/example/lib/pages/on_tap.dart index 8aba3db83..7e45d4965 100644 --- a/example/lib/pages/on_tap.dart +++ b/example/lib/pages/on_tap.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class OnTapPage extends StatefulWidget { static const String route = 'on_tap'; + const OnTapPage({Key? key}) : super(key: key); + @override OnTapPageState createState() { return OnTapPageState(); @@ -25,56 +27,53 @@ class OnTapPageState extends State { width: 80.0, height: 80.0, point: london, - builder: (ctx) => Container( - child: GestureDetector( + builder: (ctx) => GestureDetector( onTap: () { - ScaffoldMessenger.of(ctx).showSnackBar(SnackBar( + ScaffoldMessenger.of(ctx).showSnackBar(const SnackBar( content: Text('Tapped on blue FlutterLogo Marker'), )); }, - child: FlutterLogo(), - )), + child: const FlutterLogo(), + ), ), Marker( width: 80.0, height: 80.0, point: dublin, - builder: (ctx) => Container( - child: GestureDetector( + builder: (ctx) => GestureDetector( onTap: () { - ScaffoldMessenger.of(ctx).showSnackBar(SnackBar( + ScaffoldMessenger.of(ctx).showSnackBar(const SnackBar( content: Text('Tapped on green FlutterLogo Marker'), )); }, - child: FlutterLogo( + child: const FlutterLogo( textColor: Colors.green, ), - )), + ), ), Marker( width: 80.0, height: 80.0, point: paris, - builder: (ctx) => Container( - child: GestureDetector( + builder: (ctx) => GestureDetector( onTap: () { - ScaffoldMessenger.of(ctx).showSnackBar(SnackBar( + ScaffoldMessenger.of(ctx).showSnackBar(const SnackBar( content: Text('Tapped on purple FlutterLogo Marker'), )); }, - child: FlutterLogo(textColor: Colors.purple), - )), + child: const FlutterLogo(textColor: Colors.purple), + ), ), ]; return Scaffold( - appBar: AppBar(title: Text('OnTap')), + appBar: AppBar(title: const Text('OnTap')), drawer: buildDrawer(context, OnTapPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('Try tapping on the markers'), ), diff --git a/example/lib/pages/overlay_image.dart b/example/lib/pages/overlay_image.dart index 79816db2b..b0bd3498f 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -7,24 +7,26 @@ import '../widgets/drawer.dart'; class OverlayImagePage extends StatelessWidget { static const String route = 'overlay_image'; + const OverlayImagePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var overlayImages = [ OverlayImage( bounds: LatLngBounds(LatLng(51.5, -0.09), LatLng(48.8566, 2.3522)), opacity: 0.8, - imageProvider: NetworkImage( + imageProvider: const NetworkImage( 'https://images.pexels.com/photos/231009/pexels-photo-231009.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=300&w=600')), ]; return Scaffold( - appBar: AppBar(title: Text('Overlay Image')), + appBar: AppBar(title: const Text('Overlay Image')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('This is a map that is showing (51.5, -0.9).'), ), diff --git a/example/lib/pages/plugin_api.dart b/example/lib/pages/plugin_api.dart index 7c87fe600..cd6bb1750 100644 --- a/example/lib/pages/plugin_api.dart +++ b/example/lib/pages/plugin_api.dart @@ -7,13 +7,15 @@ import '../widgets/drawer.dart'; class PluginPage extends StatelessWidget { static const String route = 'plugins'; + const PluginPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Plugins')), + appBar: AppBar(title: const Text('Plugins')), drawer: buildDrawer(context, PluginPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Flexible( @@ -48,16 +50,16 @@ class MyCustomPluginOptions extends LayerOptions { MyCustomPluginOptions({ Key? key, this.text = '', - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } class MyCustomPlugin implements MapPlugin { @override Widget createLayer( - LayerOptions options, MapState mapState, Stream stream) { + LayerOptions options, MapState mapState, Stream stream) { if (options is MyCustomPluginOptions) { - var style = TextStyle( + var style = const TextStyle( fontWeight: FontWeight.bold, fontSize: 24.0, color: Colors.red, diff --git a/example/lib/pages/plugin_scalebar.dart b/example/lib/pages/plugin_scalebar.dart index 2780456b6..dce6910d0 100644 --- a/example/lib/pages/plugin_scalebar.dart +++ b/example/lib/pages/plugin_scalebar.dart @@ -8,13 +8,15 @@ import 'scale_layer_plugin_option.dart'; class PluginScaleBar extends StatelessWidget { static const String route = '/plugin_scalebar'; + const PluginScaleBar({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('ScaleBarPlugins')), + appBar: AppBar(title: const Text('ScaleBarPlugins')), drawer: buildDrawer(context, PluginScaleBar.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Flexible( @@ -37,8 +39,9 @@ class PluginScaleBar extends StatelessWidget { ScaleLayerPluginOption( lineColor: Colors.blue, lineWidth: 2, - textStyle: TextStyle(color: Colors.blue, fontSize: 12), - padding: EdgeInsets.all(10), + textStyle: + const TextStyle(color: Colors.blue, fontSize: 12), + padding: const EdgeInsets.all(10), ), ], ), diff --git a/example/lib/pages/plugin_zoombuttons.dart b/example/lib/pages/plugin_zoombuttons.dart index e2b24686b..c00d8cf01 100644 --- a/example/lib/pages/plugin_zoombuttons.dart +++ b/example/lib/pages/plugin_zoombuttons.dart @@ -8,13 +8,15 @@ import 'zoombuttons_plugin_option.dart'; class PluginZoomButtons extends StatelessWidget { static const String route = '/plugin_zoombuttons'; + const PluginZoomButtons({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('ZoomButtonsPlugins')), + appBar: AppBar(title: const Text('ZoomButtonsPlugins')), drawer: buildDrawer(context, PluginZoomButtons.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Flexible( @@ -31,7 +33,7 @@ class PluginZoomButtons extends StatelessWidget { urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c'], - tileProvider: NonCachingNetworkTileProvider(), + tileProvider: const NonCachingNetworkTileProvider(), ), ], nonRotatedLayers: [ diff --git a/example/lib/pages/polygon.dart b/example/lib/pages/polygon.dart index 112c887eb..4aac2a0e5 100644 --- a/example/lib/pages/polygon.dart +++ b/example/lib/pages/polygon.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class PolygonPage extends StatelessWidget { static const String route = 'polygon'; + const PolygonPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var notFilledPoints = [ @@ -35,13 +37,13 @@ class PolygonPage extends StatelessWidget { ]; return Scaffold( - appBar: AppBar(title: Text('Polygons')), + appBar: AppBar(title: const Text('Polygons')), drawer: buildDrawer(context, PolygonPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('Polygons'), ), diff --git a/example/lib/pages/polyline.dart b/example/lib/pages/polyline.dart index 67ef7083c..b65db5109 100644 --- a/example/lib/pages/polyline.dart +++ b/example/lib/pages/polyline.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class PolylinePage extends StatefulWidget { static const String route = 'polyline'; + const PolylinePage({Key? key}) : super(key: key); + @override State createState() => _PolylinePageState(); } @@ -26,7 +28,7 @@ class _PolylinePageState extends State { color: Colors.amber, ), ]; - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return polyLines; } @@ -51,10 +53,10 @@ class _PolylinePageState extends State { ]; return Scaffold( - appBar: AppBar(title: Text('Polylines')), + appBar: AppBar(title: const Text('Polylines')), drawer: buildDrawer(context, PolylinePage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: FutureBuilder>( future: polylines, builder: @@ -63,7 +65,7 @@ class _PolylinePageState extends State { if (snapshot.hasData) { return Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('Polylines'), ), @@ -98,9 +100,9 @@ class _PolylinePageState extends State { points: pointsGradient, strokeWidth: 4.0, gradientColors: [ - Color(0xffE40203), - Color(0xffFEED00), - Color(0xff007E2D), + const Color(0xffE40203), + const Color(0xffFEED00), + const Color(0xff007E2D), ], ), ], diff --git a/example/lib/pages/reset_tile_layer.dart b/example/lib/pages/reset_tile_layer.dart index c353d8d3c..d24d8837c 100644 --- a/example/lib/pages/reset_tile_layer.dart +++ b/example/lib/pages/reset_tile_layer.dart @@ -8,6 +8,9 @@ import '../widgets/drawer.dart'; class ResetTileLayerPage extends StatefulWidget { static const String route = '/reset_tilelayer'; + + const ResetTileLayerPage({Key? key}) : super(key: key); + @override ResetTileLayerPageState createState() { return ResetTileLayerPageState(); @@ -15,7 +18,7 @@ class ResetTileLayerPage extends StatefulWidget { } class ResetTileLayerPageState extends State { - StreamController resetController = StreamController.broadcast(); + StreamController resetController = StreamController.broadcast(); String layer1 = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; String layer2 = 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png'; @@ -40,31 +43,29 @@ class ResetTileLayerPageState extends State { width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), ]; return Scaffold( - appBar: AppBar(title: Text('TileLayer Reset')), + appBar: AppBar(title: const Text('TileLayer Reset')), drawer: buildDrawer(context, ResetTileLayerPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text( 'TileLayers can be progromatically reset, disposing of cached files'), ), Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: Wrap( children: [ MaterialButton( onPressed: _resetTiles, - child: Text('Reset'), + child: const Text('Reset'), ), ], ), diff --git a/example/lib/pages/scale_layer_plugin_option.dart b/example/lib/pages/scale_layer_plugin_option.dart index 7ab4d52c2..fc01d0e36 100644 --- a/example/lib/pages/scale_layer_plugin_option.dart +++ b/example/lib/pages/scale_layer_plugin_option.dart @@ -18,14 +18,14 @@ class ScaleLayerPluginOption extends LayerOptions { this.lineColor = Colors.white, this.lineWidth = 2, this.padding, - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } class ScaleLayerPlugin implements MapPlugin { @override Widget createLayer( - LayerOptions options, MapState mapState, Stream stream) { + LayerOptions options, MapState mapState, Stream stream) { if (options is ScaleLayerPluginOption) { return ScaleLayerWidget(options, mapState); } diff --git a/example/lib/pages/sliding_map.dart b/example/lib/pages/sliding_map.dart index d9286803c..80938f69c 100644 --- a/example/lib/pages/sliding_map.dart +++ b/example/lib/pages/sliding_map.dart @@ -7,16 +7,18 @@ import '../widgets/drawer.dart'; class SlidingMapPage extends StatelessWidget { static const String route = '/sliding_map'; + const SlidingMapPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Sliding Map')), + appBar: AppBar(title: const Text('Sliding Map')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text( 'This is a map that can be panned smoothly when the boundaries are reached.'), @@ -35,7 +37,7 @@ class SlidingMapPage extends StatelessWidget { ), layers: [ TileLayerOptions( - tileProvider: AssetTileProvider(), + tileProvider: const AssetTileProvider(), maxZoom: 14.0, urlTemplate: 'assets/map/anholt_osmbright/{z}/{x}/{y}.png', ), diff --git a/example/lib/pages/stateful_markers.dart b/example/lib/pages/stateful_markers.dart index c48469bd7..43615ff63 100644 --- a/example/lib/pages/stateful_markers.dart +++ b/example/lib/pages/stateful_markers.dart @@ -9,6 +9,8 @@ import '../widgets/drawer.dart'; class StatefulMarkersPage extends StatefulWidget { static const String route = '/stateful_markers'; + const StatefulMarkersPage({Key? key}) : super(key: key); + @override _StatefulMarkersPageState createState() => _StatefulMarkersPageState(); } @@ -39,20 +41,20 @@ class _StatefulMarkersPageState extends State { height: 40.0, point: LatLng( _random.nextDouble() * 10 + 48, _random.nextDouble() * 10 - 6), - builder: (ctx) => _ColorMarker(), + builder: (ctx) => const _ColorMarker(), key: ValueKey(key))); } @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Stateful Markers')), + appBar: AppBar(title: const Text('Stateful Markers')), drawer: buildDrawer(context, StatefulMarkersPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('This is a map that is showing (51.5, -0.9).'), ), @@ -70,7 +72,7 @@ class _StatefulMarkersPageState extends State { // For example purposes. It is recommended to use // TileProvider with a caching and retry strategy, like // NetworkTileProvider or CachedNetworkTileProvider - tileProvider: NonCachingNetworkTileProvider(), + tileProvider: const NonCachingNetworkTileProvider(), ), MarkerLayerOptions(markers: _markers) ], @@ -84,7 +86,7 @@ class _StatefulMarkersPageState extends State { } class _ColorMarker extends StatefulWidget { - _ColorMarker({Key? key}) : super(key: key); + const _ColorMarker({Key? key}) : super(key: key); @override _ColorMarkerState createState() => _ColorMarkerState(); diff --git a/example/lib/pages/tap_to_add.dart b/example/lib/pages/tap_to_add.dart index e2cd8887b..f51d63e44 100644 --- a/example/lib/pages/tap_to_add.dart +++ b/example/lib/pages/tap_to_add.dart @@ -8,6 +8,8 @@ import '../widgets/drawer.dart'; class TapToAddPage extends StatefulWidget { static const String route = '/tap'; + const TapToAddPage({Key? key}) : super(key: key); + @override State createState() { return TapToAddPageState(); @@ -24,20 +26,18 @@ class TapToAddPageState extends State { width: 80.0, height: 80.0, point: latlng, - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ); }).toList(); return Scaffold( - appBar: AppBar(title: Text('Tap to add pins')), + appBar: AppBar(title: const Text('Tap to add pins')), drawer: buildDrawer(context, TapToAddPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('Tap to add pins'), ), diff --git a/example/lib/pages/tile_builder_example.dart b/example/lib/pages/tile_builder_example.dart index bdf5f5b55..6c97bfd83 100644 --- a/example/lib/pages/tile_builder_example.dart +++ b/example/lib/pages/tile_builder_example.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class TileBuilderPage extends StatefulWidget { static const String route = '/tile_builder_example'; + const TileBuilderPage({Key? key}) : super(key: key); + @override _TileBuilderPageState createState() => _TileBuilderPageState(); } @@ -71,7 +73,7 @@ class _TileBuilderPageState extends State { icon: Icon(grid ? Icons.grid_off : Icons.grid_on), onPressed: () => setState(() => grid = !grid), ), - SizedBox(height: 8), + const SizedBox(height: 8), FloatingActionButton.extended( heroTag: 'coords', label: Text( @@ -81,7 +83,7 @@ class _TileBuilderPageState extends State { icon: Icon(showCoords ? Icons.unarchive : Icons.bug_report), onPressed: () => setState(() => showCoords = !showCoords), ), - SizedBox(height: 8), + const SizedBox(height: 8), FloatingActionButton.extended( heroTag: 'ms', label: Text( @@ -91,7 +93,7 @@ class _TileBuilderPageState extends State { icon: Icon(loadingTime ? Icons.timer_off : Icons.timer), onPressed: () => setState(() => loadingTime = !loadingTime), ), - SizedBox(height: 8), + const SizedBox(height: 8), FloatingActionButton.extended( heroTag: 'dark-light', label: Text( @@ -104,7 +106,7 @@ class _TileBuilderPageState extends State { ], ), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), @@ -114,7 +116,7 @@ class _TileBuilderPageState extends State { TileLayerOptions( urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c'], - tileProvider: NonCachingNetworkTileProvider(), + tileProvider: const NonCachingNetworkTileProvider(), tileBuilder: tileBuilder, tilesContainerBuilder: darkMode ? darkModeTilesContainerBuilder : null, @@ -125,10 +127,8 @@ class _TileBuilderPageState extends State { width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), - builder: (ctx) => Container( - child: FlutterLogo( - key: ObjectKey(Colors.blue), - ), + builder: (ctx) => const FlutterLogo( + key: ObjectKey(Colors.blue), ), ), ], diff --git a/example/lib/pages/tile_loading_error_handle.dart b/example/lib/pages/tile_loading_error_handle.dart index 03c2392c0..549e7142e 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -7,6 +7,8 @@ import '../widgets/drawer.dart'; class TileLoadingErrorHandle extends StatefulWidget { static const String route = '/tile_loading_error_handle'; + const TileLoadingErrorHandle({Key? key}) : super(key: key); + @override _TileLoadingErrorHandleState createState() => _TileLoadingErrorHandleState(); } @@ -17,13 +19,13 @@ class _TileLoadingErrorHandleState extends State { var _needLoadingError = true; return Scaffold( - appBar: AppBar(title: Text('Tile Loading Error Handle')), + appBar: AppBar(title: const Text('Tile Loading Error Handle')), drawer: buildDrawer(context, TileLoadingErrorHandle.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('Turn on Airplane mode and try to move or zoom map'), ), @@ -45,15 +47,15 @@ class _TileLoadingErrorHandleState extends State { // For example purposes. It is recommended to use // TileProvider with a caching and retry strategy, like // NetworkTileProvider or CachedNetworkTileProvider - tileProvider: NonCachingNetworkTileProvider(), + tileProvider: const NonCachingNetworkTileProvider(), errorTileCallback: (Tile tile, error) { if (_needLoadingError) { - WidgetsBinding.instance!.addPostFrameCallback((_) { + WidgetsBinding.instance?.addPostFrameCallback((_) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), content: Text( error.toString(), - style: TextStyle(color: Colors.black), + style: const TextStyle(color: Colors.black), ), backgroundColor: Colors.deepOrange, )); diff --git a/example/lib/pages/widgets.dart b/example/lib/pages/widgets.dart index 458a26a10..c004df44b 100644 --- a/example/lib/pages/widgets.dart +++ b/example/lib/pages/widgets.dart @@ -10,13 +10,15 @@ import '../widgets/drawer.dart'; class WidgetsPage extends StatelessWidget { static const String route = 'widgets'; + const WidgetsPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Widgets')), + appBar: AppBar(title: const Text('Widgets')), drawer: buildDrawer(context, WidgetsPage.route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ Flexible( @@ -37,7 +39,7 @@ class WidgetsPage extends StatelessWidget { alignment: Alignment.bottomLeft, ) ], - nonRotatedChildren: [ + nonRotatedChildren: const [ Text( 'Plugin is just Text widget', style: TextStyle( @@ -55,7 +57,7 @@ class WidgetsPage extends StatelessWidget { subdomains: ['a', 'b', 'c'], ), ), - MovingWithoutRefreshAllMapMarkers(), + const MovingWithoutRefreshAllMapMarkers(), ], ), ), @@ -67,6 +69,8 @@ class WidgetsPage extends StatelessWidget { } class MovingWithoutRefreshAllMapMarkers extends StatefulWidget { + const MovingWithoutRefreshAllMapMarkers({Key? key}) : super(key: key); + @override State createState() => _MovingWithoutRefreshAllMapMarkersState(); @@ -82,7 +86,7 @@ class _MovingWithoutRefreshAllMapMarkersState void initState() { super.initState(); _marker = _markers[_markerIndex]; - _timer = Timer.periodic(Duration(seconds: 1), (_) { + _timer = Timer.periodic(const Duration(seconds: 1), (_) { setState(() { _marker = _markers[_markerIndex]; _markerIndex = (_markerIndex + 1) % _markers.length; @@ -109,24 +113,18 @@ List _markers = [ width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), Marker( width: 80.0, height: 80.0, point: LatLng(53.3498, -6.2603), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), Marker( width: 80.0, height: 80.0, point: LatLng(48.8566, 2.3522), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), ]; diff --git a/example/lib/pages/wms_tile_layer.dart b/example/lib/pages/wms_tile_layer.dart index 480103f7e..34bece41b 100644 --- a/example/lib/pages/wms_tile_layer.dart +++ b/example/lib/pages/wms_tile_layer.dart @@ -7,16 +7,18 @@ import '../widgets/drawer.dart'; class WMSLayerPage extends StatelessWidget { static const String route = 'WMS layer'; + const WMSLayerPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('WMS Layer')), + appBar: AppBar(title: const Text('WMS Layer')), drawer: buildDrawer(context, route), body: Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Text('This is a map that is showing (42.58, 12.43).'), ), diff --git a/example/lib/pages/zoombuttons_plugin_option.dart b/example/lib/pages/zoombuttons_plugin_option.dart index 0c91ba4fe..4cb96af60 100644 --- a/example/lib/pages/zoombuttons_plugin_option.dart +++ b/example/lib/pages/zoombuttons_plugin_option.dart @@ -27,14 +27,14 @@ class ZoomButtonsPluginOption extends LayerOptions { this.zoomOutColor, this.zoomOutColorIcon, this.zoomOutIcon = Icons.zoom_out, - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } class ZoomButtonsPlugin implements MapPlugin { @override Widget createLayer( - LayerOptions options, MapState mapState, Stream stream) { + LayerOptions options, MapState mapState, Stream stream) { if (options is ZoomButtonsPluginOption) { return ZoomButtons(options, mapState, stream); } @@ -50,7 +50,7 @@ class ZoomButtonsPlugin implements MapPlugin { class ZoomButtons extends StatelessWidget { final ZoomButtonsPluginOption zoomButtonsOpts; final MapState map; - final Stream stream; + final Stream stream; final FitBoundsOptions options = const FitBoundsOptions(padding: EdgeInsets.all(12.0)); diff --git a/example/lib/test_app.dart b/example/lib/test_app.dart index 830cb98b9..d3548703d 100644 --- a/example/lib/test_app.dart +++ b/example/lib/test_app.dart @@ -3,10 +3,12 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:latlong2/latlong.dart'; void main() { - runApp(TestApp()); + runApp(const TestApp()); } class TestApp extends StatefulWidget { + const TestApp({Key? key}) : super(key: key); + @override _TestAppState createState() => _TestAppState(); } @@ -22,7 +24,7 @@ class _TestAppState extends State { return MaterialApp( home: Scaffold( body: Center( - child: Container( + child: SizedBox( width: 200, height: 200, child: FlutterMap( diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 78027d9c4..3da92d5c6 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -31,9 +31,9 @@ dependencies: location: ^4.1.1 dev_dependencies: + flutter_lints: ^1.0.4 flutter_test: sdk: flutter - pedantic: ^1.11.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 40d49f95d..61052758d 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -65,7 +65,7 @@ class FlutterMap extends StatefulWidget { final MapOptions options; /// A [MapController], used to control the map. - final MapControllerImpl? _mapController; + final MapController mapController; FlutterMap({ Key? key, @@ -75,11 +75,11 @@ class FlutterMap extends StatefulWidget { this.children = const [], this.nonRotatedChildren = const [], MapController? mapController, - }) : _mapController = mapController as MapControllerImpl?, + }) : mapController = mapController ?? MapController(), super(key: key); @override - FlutterMapState createState() => FlutterMapState(_mapController); + FlutterMapState createState() => FlutterMapState(); } /// Controller to programmatically interact with [FlutterMap]. @@ -126,7 +126,7 @@ abstract class MapController { CenterZoom centerZoomFitBounds(LatLngBounds bounds, {FitBoundsOptions? options}); - Future get onReady; + Future get onReady; LatLng get center; @@ -137,6 +137,9 @@ abstract class MapController { double get rotation; Stream get mapEventStream; + StreamSink get mapEventSink; + set state(MapState state); + void dispose(); factory MapController() => MapControllerImpl(); } diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index fadb9e511..2bc0c4c96 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -29,7 +29,7 @@ abstract class Crs { var scale = this.scale(zoom); return transformation.transform(projectedPoint, scale.toDouble()); } catch (e) { - return CustomPoint(0.0, 0.0); + return const CustomPoint(0.0, 0.0); } } @@ -86,7 +86,7 @@ class CrsSimple extends Crs { CrsSimple() : projection = const _LonLat(), - transformation = Transformation(1, 0, -1, 0), + transformation = const Transformation(1, 0, -1, 0), super(); @override @@ -211,7 +211,7 @@ class Proj4Crs extends Crs { } if (null == origins || origins.isEmpty) { - transformation ??= Transformation(1, 0, -1, 0); + transformation ??= const Transformation(1, 0, -1, 0); } else { if (origins.length == 1) { var origin = origins[0]; @@ -244,7 +244,7 @@ class Proj4Crs extends Crs { return transformation.transform(projectedPoint, scale.toDouble()); } catch (e) { - return CustomPoint(0.0, 0.0); + return const CustomPoint(0.0, 0.0); } } @@ -370,7 +370,8 @@ abstract class Projection { class _LonLat extends Projection { static final Bounds _bounds = Bounds( - CustomPoint(-180.0, -90.0), CustomPoint(180.0, 90.0)); + const CustomPoint(-180.0, -90.0), + const CustomPoint(180.0, 90.0)); const _LonLat() : super(); @@ -394,8 +395,8 @@ class SphericalMercator extends Projection { static const double maxLatitude = 85.0511287798; static const double _boundsD = r * math.pi; static final Bounds _bounds = Bounds( - CustomPoint(-_boundsD, -_boundsD), - CustomPoint(_boundsD, _boundsD), + const CustomPoint(-_boundsD, -_boundsD), + const CustomPoint(_boundsD, _boundsD), ); const SphericalMercator() : super(); diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index d2b32e280..83adb3c1c 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -94,10 +94,10 @@ abstract class MapGestureMixin extends State _flingController = AnimationController(vsync: this) ..addListener(_handleFlingAnimation) ..addStatusListener(_flingAnimationStatusListener); - _doubleTapController = - AnimationController(vsync: this, duration: Duration(milliseconds: 200)) - ..addListener(_handleDoubleTapZoomAnimation) - ..addStatusListener(_doubleTapZoomStatusListener); + _doubleTapController = AnimationController( + vsync: this, duration: const Duration(milliseconds: 200)) + ..addListener(_handleDoubleTapZoomAnimation) + ..addStatusListener(_doubleTapZoomStatusListener); } @override @@ -326,20 +326,20 @@ abstract class MapGestureMixin extends State .abs() >= options.pinchZoomThreshold) { if (options.debugMultiFingerGestureWinner) { - print('Multi Finger Gesture winner: Pinch Zoom'); + debugPrint('Multi Finger Gesture winner: Pinch Zoom'); } _yieldMultiFingerGestureWinner(MultiFingerGesture.pinchZoom, true); } else if (hasIntRotate && currentRotation.abs() >= options.rotationThreshold) { if (options.debugMultiFingerGestureWinner) { - print('Multi Finger Gesture winner: Rotate'); + debugPrint('Multi Finger Gesture winner: Rotate'); } _yieldMultiFingerGestureWinner(MultiFingerGesture.rotate, true); } else if (hasIntPinchMove && (_focalStartLocal - focalOffset).distance >= options.pinchMoveThreshold) { if (options.debugMultiFingerGestureWinner) { - print('Multi Finger Gesture winner: Pinch Move'); + debugPrint('Multi Finger Gesture winner: Pinch Move'); } _yieldMultiFingerGestureWinner(MultiFingerGesture.pinchMove, true); } diff --git a/lib/src/layer/circle_layer.dart b/lib/src/layer/circle_layer.dart index 7a3b34bd8..72884fc61 100644 --- a/lib/src/layer/circle_layer.dart +++ b/lib/src/layer/circle_layer.dart @@ -8,7 +8,7 @@ class CircleLayerOptions extends LayerOptions { CircleLayerOptions({ Key? key, this.circles = const [], - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -34,7 +34,7 @@ class CircleMarker { class CircleLayerWidget extends StatelessWidget { final CircleLayerOptions options; - CircleLayerWidget({Key? key, required this.options}) : super(key: key); + const CircleLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { @@ -46,7 +46,7 @@ class CircleLayerWidget extends StatelessWidget { class CircleLayer extends StatelessWidget { final CircleLayerOptions circleOpts; final MapState map; - final Stream? stream; + final Stream? stream; CircleLayer(this.circleOpts, this.map, this.stream) : super(key: circleOpts.key); @@ -72,7 +72,7 @@ class CircleLayer extends StatelessWidget { circle.offset = Offset(pos.x.toDouble(), pos.y.toDouble()); if (circle.useRadiusInMeter) { - var r = Distance().offset(circle.point, circle.radius, 180); + var r = const Distance().offset(circle.point, circle.radius, 180); var rpos = map.project(r); rpos = rpos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - map.getPixelOrigin(); @@ -88,10 +88,8 @@ class CircleLayer extends StatelessWidget { ); } - return Container( - child: Stack( - children: circleWidgets, - ), + return Stack( + children: circleWidgets, ); }, ); @@ -135,5 +133,5 @@ class CirclePainter extends CustomPainter { } @override - bool shouldRepaint(CirclePainter other) => false; + bool shouldRepaint(CirclePainter oldDelegate) => false; } diff --git a/lib/src/layer/group_layer.dart b/lib/src/layer/group_layer.dart index 30a3ea3bd..5980d78af 100644 --- a/lib/src/layer/group_layer.dart +++ b/lib/src/layer/group_layer.dart @@ -9,14 +9,14 @@ class GroupLayerOptions extends LayerOptions { GroupLayerOptions({ Key? key, this.group = const [], - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } class GroupLayerWidget extends StatelessWidget { final GroupLayerOptions options; - GroupLayerWidget({Key? key, required this.options}) : super(key: key); + const GroupLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { @@ -28,7 +28,7 @@ class GroupLayerWidget extends StatelessWidget { class GroupLayer extends StatelessWidget { final GroupLayerOptions groupOpts; final MapState map; - final Stream stream; + final Stream stream; GroupLayer(this.groupOpts, this.map, this.stream) : super(key: groupOpts.key); @@ -41,10 +41,8 @@ class GroupLayer extends StatelessWidget { for (var options in groupOpts.group) _createLayer(options) ]; - return Container( - child: Stack( - children: layers, - ), + return Stack( + children: layers, ); }, ); diff --git a/lib/src/layer/layer.dart b/lib/src/layer/layer.dart index cf4cb0801..8863b8041 100644 --- a/lib/src/layer/layer.dart +++ b/lib/src/layer/layer.dart @@ -6,6 +6,6 @@ import 'package:flutter/foundation.dart'; /// rebuilding. class LayerOptions { final Key? key; - final Stream? rebuild; + final Stream? rebuild; LayerOptions({this.key, this.rebuild}); } diff --git a/lib/src/layer/marker_layer.dart b/lib/src/layer/marker_layer.dart index 22b89e1bc..1843876d7 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -43,7 +43,7 @@ class MarkerLayerOptions extends LayerOptions { this.rotateOrigin, this.rotateAlignment = Alignment.center, this.usePxCache = true, - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -165,7 +165,7 @@ class Marker { class MarkerLayerWidget extends StatelessWidget { final MarkerLayerOptions options; - MarkerLayerWidget({Key? key, required this.options}) : super(key: key); + const MarkerLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { @@ -177,7 +177,7 @@ class MarkerLayerWidget extends StatelessWidget { class MarkerLayer extends StatefulWidget { final MarkerLayerOptions markerLayerOptions; final MapState map; - final Stream? stream; + final Stream? stream; MarkerLayer(this.markerLayerOptions, this.map, this.stream) : super(key: markerLayerOptions.key); @@ -236,9 +236,9 @@ class _MarkerLayerState extends State { @override Widget build(BuildContext context) { - return StreamBuilder( - stream: widget.stream, // a Stream or null - builder: (BuildContext context, AsyncSnapshot snapshot) { + return StreamBuilder( + stream: widget.stream, + builder: (BuildContext context, AsyncSnapshot snapshot) { var layerOptions = widget.markerLayerOptions; var map = widget.map; var usePxCache = layerOptions.usePxCache; @@ -291,10 +291,8 @@ class _MarkerLayerState extends State { ); } lastZoom = map.zoom; - return Container( - child: Stack( - children: markers, - ), + return Stack( + children: markers, ); }, ); diff --git a/lib/src/layer/overlay_image_layer.dart b/lib/src/layer/overlay_image_layer.dart index 1d6fe1048..8df75667c 100644 --- a/lib/src/layer/overlay_image_layer.dart +++ b/lib/src/layer/overlay_image_layer.dart @@ -10,7 +10,7 @@ class OverlayImageLayerOptions extends LayerOptions { OverlayImageLayerOptions({ Key? key, this.overlayImages = const [], - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -31,7 +31,8 @@ class OverlayImage { class OverlayImageLayerWidget extends StatelessWidget { final OverlayImageLayerOptions options; - OverlayImageLayerWidget({Key? key, required this.options}) : super(key: key); + const OverlayImageLayerWidget({Key? key, required this.options}) + : super(key: key); @override Widget build(BuildContext context) { @@ -43,7 +44,7 @@ class OverlayImageLayerWidget extends StatelessWidget { class OverlayImageLayer extends StatelessWidget { final OverlayImageLayerOptions overlayImageOpts; final MapState map; - final Stream? stream; + final Stream? stream; OverlayImageLayer(this.overlayImageOpts, this.map, this.stream) : super(key: overlayImageOpts.key); diff --git a/lib/src/layer/polygon_layer.dart b/lib/src/layer/polygon_layer.dart index 201c880eb..056bb2183 100644 --- a/lib/src/layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer.dart @@ -16,7 +16,7 @@ class PolygonLayerOptions extends LayerOptions { Key? key, this.polygons = const [], this.polygonCulling = false, - Stream? rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild) { if (polygonCulling) { for (var polygon in polygons) { @@ -59,7 +59,7 @@ class Polygon { class PolygonLayerWidget extends StatelessWidget { final PolygonLayerOptions options; - PolygonLayerWidget({Key? key, required this.options}) : super(key: key); + const PolygonLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { @@ -71,7 +71,7 @@ class PolygonLayerWidget extends StatelessWidget { class PolygonLayer extends StatelessWidget { final PolygonLayerOptions polygonOpts; final MapState map; - final Stream? stream; + final Stream? stream; PolygonLayer(this.polygonOpts, this.map, this.stream) : super(key: polygonOpts.key); @@ -126,10 +126,8 @@ class PolygonLayer extends StatelessWidget { ); } - return Container( - child: Stack( - children: polygons, - ), + return Stack( + children: polygons, ); }, ); @@ -276,7 +274,7 @@ class PolygonPainter extends CustomPainter { } @override - bool shouldRepaint(PolygonPainter other) => false; + bool shouldRepaint(PolygonPainter oldDelegate) => false; double _dist(Offset v, Offset w) { return sqrt(_dist2(v, w)); diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 477833470..4f1edcf89 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -26,7 +26,7 @@ class PolylineLayerOptions extends LayerOptions { Key? key, this.polylines = const [], this.polylineCulling = false, - Stream? rebuild, + Stream? rebuild, this.saveLayers = false, }) : super(key: key, rebuild: rebuild) { if (polylineCulling) { @@ -68,7 +68,8 @@ class Polyline { class PolylineLayerWidget extends StatelessWidget { final PolylineLayerOptions options; - PolylineLayerWidget({Key? key, required this.options}) : super(key: key); + const PolylineLayerWidget({Key? key, required this.options}) + : super(key: key); @override Widget build(BuildContext context) { @@ -80,7 +81,7 @@ class PolylineLayerWidget extends StatelessWidget { class PolylineLayer extends StatelessWidget { final PolylineLayerOptions polylineOpts; final MapState map; - final Stream? stream; + final Stream? stream; PolylineLayer(this.polylineOpts, this.map, this.stream) : super(key: polylineOpts.key); @@ -118,10 +119,8 @@ class PolylineLayer extends StatelessWidget { )); } - return Container( - child: Stack( - children: polylines, - ), + return Stack( + children: polylines, ); }, ); @@ -186,7 +185,7 @@ class PolylinePainter extends CustomPainter { final borderPaint = polylineOpt.borderStrokeWidth > 0.0 ? (Paint() - ..color = polylineOpt.borderColor ?? Color(0x00000000) + ..color = polylineOpt.borderColor ?? const Color(0x00000000) ..strokeWidth = polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth ..strokeCap = polylineOpt.strokeCap @@ -270,7 +269,7 @@ class PolylinePainter extends CustomPainter { } @override - bool shouldRepaint(PolylinePainter other) => false; + bool shouldRepaint(PolylinePainter oldDelegate) => false; } double _dist(Offset v, Offset w) { diff --git a/lib/src/layer/tile_builder/tile_builder.dart b/lib/src/layer/tile_builder/tile_builder.dart index 32388d2b4..19868bf6d 100644 --- a/lib/src/layer/tile_builder/tile_builder.dart +++ b/lib/src/layer/tile_builder/tile_builder.dart @@ -8,8 +8,11 @@ typedef TilesContainerBuilder = Widget Function( BuildContext context, Widget tilesContainer, List tiles); /// Applies inversion color matrix on Tiles container which may simulate Dark mode. -final TilesContainerBuilder darkModeTilesContainerBuilder = - (BuildContext context, Widget tilesContainer, List tiles) { +Widget darkModeTilesContainerBuilder( + BuildContext context, + Widget tilesContainer, + List tiles, +) { return ColorFiltered( colorFilter: const ColorFilter.matrix([ -1, @@ -35,12 +38,15 @@ final TilesContainerBuilder darkModeTilesContainerBuilder = ]), child: tilesContainer, ); -}; +} /// Applies inversion color matrix on Tiles which may simulate Dark mode. /// [darkModeTilesContainerBuilder] is better at performance because it applies color matrix on the container instead of on every Tile -final TileBuilder darkModeTileBuilder = - (BuildContext context, Widget tileWidget, Tile tile) { +Widget darkModeTileBuilder( + BuildContext context, + Widget tileWidget, + Tile tile, +) { return ColorFiltered( colorFilter: const ColorFilter.matrix([ -1, @@ -66,11 +72,14 @@ final TileBuilder darkModeTileBuilder = ]), child: tileWidget, ); -}; +} /// Shows coordinates over Tiles -final TileBuilder coordinateDebugTileBuilder = - (BuildContext context, Widget tileWidget, Tile tile) { +Widget coordinateDebugTileBuilder( + BuildContext context, + Widget tileWidget, + Tile tile, +) { final coords = tile.coords; final readableKey = '${coords.x.floor()} : ${coords.y.floor()} : ${coords.z.floor()}'; @@ -92,11 +101,14 @@ final TileBuilder coordinateDebugTileBuilder = ], ), ); -}; +} /// Shows the Tile loading time in ms -final TileBuilder loadingTimeDebugTileBuilder = - (BuildContext context, Widget tileWidget, Tile tile) { +Widget loadingTimeDebugTileBuilder( + BuildContext context, + Widget tileWidget, + Tile tile, +) { var loadStarted = tile.loadStarted; var loaded = tile.loaded; @@ -121,4 +133,4 @@ final TileBuilder loadingTimeDebugTileBuilder = ], ), ); -}; +} diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 2b37f8400..61aafc1b9 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -242,7 +242,7 @@ class TileLayerOptions extends LayerOptions { final Alignment attributionAlignment; /// Stream to notify the [TileLayer] that it needs resetting - Stream? reset; + Stream? reset; /// Only load tiles that are within these bounds LatLngBounds? tileBounds; @@ -287,7 +287,7 @@ class TileLayerOptions extends LayerOptions { this.overrideTilesWhenUrlChanges = false, this.retinaMode = false, this.errorTileCallback, - Stream? rebuild, + Stream? rebuild, this.templateFunction = util.template, this.tileBuilder, this.tilesContainerBuilder, @@ -417,7 +417,7 @@ class WMSTileLayerOptions { class TileLayerWidget extends StatelessWidget { final TileLayerOptions options; - TileLayerWidget({Key? key, required this.options}) : super(key: key); + const TileLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { @@ -434,7 +434,7 @@ class TileLayerWidget extends StatelessWidget { class TileLayer extends StatefulWidget { final TileLayerOptions options; final MapState mapState; - final Stream stream; + final Stream stream; TileLayer({ required this.options, @@ -1142,7 +1142,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { void _tileReady(Coords coords, dynamic error, Tile? tile) { if (null != error) { - print(error); + debugPrint(error.toString()); tile!.loadError = true; @@ -1292,7 +1292,7 @@ class Tile implements Comparable { try { final oldImageStream = _imageStream; - _imageStream = imageProvider.resolve(ImageConfiguration()); + _imageStream = imageProvider.resolve(const ImageConfiguration()); if (_imageStream!.key != oldImageStream?.key) { oldImageStream?.removeListener(_listener); @@ -1311,11 +1311,13 @@ class Tile implements Comparable { if (evict) { try { // ignore: return_type_invalid_for_catch_error - imageProvider.evict().catchError(print); + imageProvider.evict().catchError((e) { + debugPrint(e.toString()); + }); } catch (e) { // this may be never called because catchError will handle errors, however // we want to avoid random crashes like in #444 / #536 - print(e); + debugPrint(e.toString()); } } @@ -1380,7 +1382,7 @@ class AnimatedTile extends StatefulWidget { final ImageProvider? errorImage; final TileBuilder? tileBuilder; - AnimatedTile({ + const AnimatedTile({ Key? key, required this.tile, this.errorImage, diff --git a/lib/src/map/flutter_map_state.dart b/lib/src/map/flutter_map_state.dart index eb7740c7a..d3bbc28de 100644 --- a/lib/src/map/flutter_map_state.dart +++ b/lib/src/map/flutter_map_state.dart @@ -10,9 +10,7 @@ import 'package:flutter_map/src/map/map_state_widget.dart'; import 'package:positioned_tap_detector_2/positioned_tap_detector_2.dart'; class FlutterMapState extends MapGestureMixin { - @override - final MapControllerImpl mapController; - final List> groups = >[]; + final List> groups = >[]; final _positionedTapController = PositionedTapController(); @override @@ -21,9 +19,8 @@ class FlutterMapState extends MapGestureMixin { @override late final MapState mapState; - FlutterMapState(MapController? mapController) - : mapController = mapController as MapControllerImpl? ?? - MapController() as MapControllerImpl; + @override + MapController get mapController => widget.mapController; @override void didUpdateWidget(FlutterMap oldWidget) { @@ -63,10 +60,10 @@ class FlutterMapState extends MapGestureMixin { super.dispose(); } - Stream _merge(LayerOptions options) { + Stream _merge(LayerOptions options) { if (options.rebuild == null) return mapState.onMoved; - var group = StreamGroup(); + var group = StreamGroup(); group.add(mapState.onMoved); group.add(options.rebuild!); groups.add(group); @@ -92,7 +89,7 @@ class FlutterMapState extends MapGestureMixin { var scaleGestureTeam = GestureArenaTeam(); - var scaleGestureDetector = ({required Widget child}) => + RawGestureDetector scaleGestureDetector({required Widget child}) => RawGestureDetector( gestures: { ScaleGestureRecognizer: diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index 6a87d9bc5..43c359488 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -8,18 +8,21 @@ import 'package:flutter_map/src/map/map_state_widget.dart'; import 'package:latlong2/latlong.dart'; class MapControllerImpl implements MapController { - final Completer _readyCompleter = Completer(); + final Completer _readyCompleter = Completer(); final StreamController _mapEventSink = StreamController.broadcast(); + @override StreamSink get mapEventSink => _mapEventSink.sink; - late final MapState _state; @override - Future get onReady => _readyCompleter.future; + Future get onReady => _readyCompleter.future; + @override void dispose() { _mapEventSink.close(); } + late final MapState _state; + @override set state(MapState state) { _state = state; if (!_readyCompleter.isCompleted) { @@ -82,7 +85,7 @@ class MapControllerImpl implements MapController { class MapState { MapOptions options; final ValueChanged onRotationChanged; - final StreamController _onMoveSink; + final StreamController _onMoveSink; final StreamSink _mapEventSink; double _zoom; @@ -111,7 +114,7 @@ class MapState { _zoom = options.zoom, _onMoveSink = StreamController.broadcast(); - Stream get onMoved => _onMoveSink.stream; + Stream get onMoved => _onMoveSink.stream; // Original size of the map where rotation isn't calculated CustomPoint? _originalSize; @@ -137,7 +140,7 @@ class MapState { // Extended size of the map where rotation is calculated CustomPoint? _size; - CustomPoint get size => _size ?? CustomPoint(0.0, 0.0); + CustomPoint get size => _size ?? const CustomPoint(0.0, 0.0); void _updateSizeByOriginalSizeAndRotation() { final originalWidth = _originalSize!.x; diff --git a/lib/src/map/map_state_widget.dart b/lib/src/map/map_state_widget.dart index 661409229..95f8a2dc9 100644 --- a/lib/src/map/map_state_widget.dart +++ b/lib/src/map/map_state_widget.dart @@ -5,7 +5,7 @@ import 'map.dart'; class MapStateInheritedWidget extends InheritedWidget { final MapState mapState; - MapStateInheritedWidget({ + const MapStateInheritedWidget({ Key? key, required this.mapState, required Widget child, diff --git a/lib/src/plugins/plugin.dart b/lib/src/plugins/plugin.dart index 9e659a847..04062082e 100644 --- a/lib/src/plugins/plugin.dart +++ b/lib/src/plugins/plugin.dart @@ -5,5 +5,5 @@ import 'package:flutter_map/src/map/map.dart'; abstract class MapPlugin { bool supportsLayer(LayerOptions options); Widget createLayer( - LayerOptions options, MapState mapState, Stream stream); + LayerOptions options, MapState mapState, Stream stream); } diff --git a/pubspec.yaml b/pubspec.yaml index de262da47..51ca8afaf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,9 +23,9 @@ dependencies: vector_math: ^2.1.0 dev_dependencies: + flutter_lints: ^1.0.4 flutter_test: sdk: flutter location: ^4.1.1 mockito: ^5.0.2 - pedantic: ^1.11.0 test: ^1.16.8 \ No newline at end of file diff --git a/test/core/bounds_test.dart b/test/core/bounds_test.dart index 4eb522608..3c078a148 100644 --- a/test/core/bounds_test.dart +++ b/test/core/bounds_test.dart @@ -9,7 +9,8 @@ void main() { test( 'should create bounds with minimum point equal to minimum argument ' 'if maximum argument point is positioned higher', () { - final bounds = Bounds(CustomPoint(1.0, 2.0), CustomPoint(3.0, 4.0)); + final bounds = + Bounds(const CustomPoint(1.0, 2.0), const CustomPoint(3.0, 4.0)); expect(bounds.min.x, equals(1.0)); expect(bounds.min.y, equals(2.0)); @@ -18,7 +19,8 @@ void main() { test( 'should create bounds with minimum point equal to maximum argument ' 'if maximum argument point is positioned lower', () { - final bounds = Bounds(CustomPoint(3.0, 4.0), CustomPoint(1.0, 2.0)); + final bounds = + Bounds(const CustomPoint(3.0, 4.0), const CustomPoint(1.0, 2.0)); expect(bounds.min.x, equals(1.0)); expect(bounds.min.y, equals(2.0)); @@ -27,7 +29,8 @@ void main() { test( 'should create bounds with maximum point equal to minimum argument ' 'if maximum argument point is positioned lower', () { - final bounds = Bounds(CustomPoint(1.0, 2.0), CustomPoint(0.01, 0.02)); + final bounds = + Bounds(const CustomPoint(1.0, 2.0), const CustomPoint(0.01, 0.02)); expect(bounds.max.x, equals(1.0)); expect(bounds.max.y, equals(2.0)); @@ -36,7 +39,8 @@ void main() { test( 'should create bounds with maximum point equal to maximum argument ' 'if maximum argument point is positioned higher', () { - final bounds = Bounds(CustomPoint(0.01, 0.02), CustomPoint(1.0, 2.0)); + final bounds = + Bounds(const CustomPoint(0.01, 0.02), const CustomPoint(1.0, 2.0)); expect(bounds.max.x, equals(1.0)); expect(bounds.max.y, equals(2.0)); @@ -175,7 +179,9 @@ void main() { }); test('should be convertable to string', () { - expect(Bounds(CustomPoint(1.1, 2.2), CustomPoint(3.3, 4.4)).toString(), + expect( + Bounds(const CustomPoint(1.1, 2.2), const CustomPoint(3.3, 4.4)) + .toString(), equals('Bounds(CustomPoint (1.1, 2.2), CustomPoint (3.3, 4.4))')); }); @@ -250,62 +256,62 @@ void main() { test( 'should contain compared bounds if they are completely within ' 'the bounds', () { - final bounds = - Bounds(CustomPoint(101.1, 88.1), CustomPoint(133.1, 60.3)); + final bounds = Bounds( + const CustomPoint(101.1, 88.1), const CustomPoint(133.1, 60.3)); expect( - bounds.containsBounds( - Bounds(CustomPoint(110.1, 77.3), CustomPoint(128.3, 65.5))), + bounds.containsBounds(Bounds(const CustomPoint(110.1, 77.3), + const CustomPoint(128.3, 65.5))), isTrue); }); test( 'should NOT contain compared bounds if they are NOT completely ' 'within the bounds', () { - final bounds = - Bounds(CustomPoint(101.1, 88.1), CustomPoint(133.1, 60.3)); + final bounds = Bounds( + const CustomPoint(101.1, 88.1), const CustomPoint(133.1, 60.3)); expect( - bounds.containsBounds( - Bounds(CustomPoint(110.1, 77.3), CustomPoint(133.2, 65.5))), + bounds.containsBounds(Bounds(const CustomPoint(110.1, 77.3), + const CustomPoint(133.2, 65.5))), isFalse); }); test( 'should contain compared bounds partially if at least one edge ' 'overlaps within the bounds', () { - final bounds = - Bounds(CustomPoint(101.1, 88.1), CustomPoint(133.1, 60.3)); + final bounds = Bounds( + const CustomPoint(101.1, 88.1), const CustomPoint(133.1, 60.3)); expect( - bounds.containsPartialBounds( - Bounds(CustomPoint(200.22, 60.2), CustomPoint(133.1, 60.3))), + bounds.containsPartialBounds(Bounds(const CustomPoint(200.22, 60.2), + const CustomPoint(133.1, 60.3))), isTrue); }); test( 'should NOT contain compared bounds partially if not a single edge ' 'overlaps within the bounds', () { - final bounds = - Bounds(CustomPoint(101.1, 88.1), CustomPoint(133.1, 60.3)); + final bounds = Bounds( + const CustomPoint(101.1, 88.1), const CustomPoint(133.1, 60.3)); expect( - bounds.containsPartialBounds( - Bounds(CustomPoint(200.22, 60.2), CustomPoint(133.2, 60.3))), + bounds.containsPartialBounds(Bounds(const CustomPoint(200.22, 60.2), + const CustomPoint(133.2, 60.3))), isFalse); }); test('should contain given point within the bounds', () { expect( - Bounds(CustomPoint(0.0, 50.0), CustomPoint(50.0, 0.0)) - .contains(CustomPoint(25.0, 25.0)), + Bounds(const CustomPoint(0.0, 50.0), const CustomPoint(50.0, 0.0)) + .contains(const CustomPoint(25.0, 25.0)), isTrue); }); test('should NOT contain given point within the bounds', () { expect( - Bounds(CustomPoint(0.0, 50.0), CustomPoint(50.0, 0.0)) - .contains(CustomPoint(50.1, 50.1)), + Bounds(const CustomPoint(0.0, 50.0), const CustomPoint(50.0, 0.0)) + .contains(const CustomPoint(50.1, 50.1)), isFalse); }); }); diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index 48a86f330..f65f29371 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -54,7 +54,7 @@ class MockHttpOverrides extends HttpOverrides { void main() { testWidgets('flutter_map', (tester) async { HttpOverrides.global = MockHttpOverrides(); - await tester.pumpWidget(TestApp()); + await tester.pumpWidget(const TestApp()); expect(find.byType(FlutterMap), findsOneWidget); expect(find.byType(TileLayer), findsOneWidget); expect(find.byType(RawImage), findsWidgets); @@ -64,6 +64,8 @@ void main() { } class TestApp extends StatefulWidget { + const TestApp({Key? key}) : super(key: key); + @override _TestAppState createState() => _TestAppState(); } @@ -74,17 +76,13 @@ class _TestAppState extends State { width: 80.0, height: 80.0, point: LatLng(45.5231, -122.6765), - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), Marker( width: 80.0, height: 80.0, point: LatLng(40, -120), // not visible - builder: (ctx) => Container( - child: FlutterLogo(), - ), + builder: (ctx) => const FlutterLogo(), ), ]; @@ -98,7 +96,7 @@ class _TestAppState extends State { return MaterialApp( home: Scaffold( body: Center( - child: Container( + child: SizedBox( width: 200, height: 200, child: FlutterMap(