tlserver / flutter_map_location_marker

A flutter map plugin for displaying device current location.
https://pub.dev/packages/flutter_map_location_marker
BSD 3-Clause "New" or "Revised" License
97 stars 81 forks source link

Package size too large. #55

Closed TristanGrobler closed 1 year ago

TristanGrobler commented 1 year ago

Builing an APK before adding the package resulted in 26.4 MB APK. Adding the package to pubspec.yaml, running futter pub get and then building APK resulted in a 60.5 MB APK. Both sizes are for release APK. Screenshot 2023-02-10 at 13 39 52

tlserver commented 1 year ago

This is a known issue caused by hemanthrajv/flutter_compass#92. I cannot found any alternative package to replace this package last year. I am planning to write a new package to receive heading angle from the device after June 2023 if this issue and other existing issues are not fixed and there are still no alternative package exist.

TristanGrobler commented 1 year ago

Have you tried this?

I just added it to my current project and it only bumped it up less than a mb.

tlserver commented 1 year ago

Here is my test result. image After adding this plugin the size is not increated too much for release apk. for the settings of -16, the minSdkVersion is set to flutter.minSdkVersion, and it include flutter_map as dependencies. for the settings of -23, the minSdkVersion is set to 23, and it include flutter_map as dependencies. for the settings of *-fmlm, the minSdkVersion is set to 23, and it include flutter_map and this plugin as dependencies.

Steps for my test: Create a flutter project named fmlm_size. Paste this code to main.dart:

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
// import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Size',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Size"),
      ),
      body: FlutterMap(
        options: MapOptions(
          zoom: 1,
          minZoom: 0,
          maxZoom: 19,
        ),
        children: [
          TileLayer(
            urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            subdomains: const ['a', 'b', 'c'],
            userAgentPackageName:
            'net.tlserver6y.flutter_map_location_marker.example',
            maxZoom: 19,
          ),
          // CurrentLocationLayer(),
        ],
      ),
    );
  }
}

Paste this code to pubspec.yaml:

name: fmlm_size
description: size
publish_to: 'none'

version: 1.0.0+1

environment:
  sdk: '>=2.19.0 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_map: any
#  flutter_map_location_marker: any

  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0

flutter:

  uses-material-design: true

Run pub get. Run flutter build apk and flutter build apk --debug. Add postfix -16 to two apks. Edit app/build.gradle, change minSdkVersion from flutter.minSdkVersion to 23. Add this code to app/src/main/AndroidManifest.xml after <manifest ...> and before <application ...>:

   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Run flutter build apk and flutter build apk --debug. Add postfix -23 to two apks. Uncomment import 'package:flutter_map_location_marker/flutter_map_location_marker.dart'; and CurrentLocationLayer(), in main.dart. Uncomment flutter_map_location_marker: any in pubspec.yaml. Run pub get. Run flutter build apk and flutter build apk --debug. Add postfix -fmlm to two apks.

TristanGrobler commented 1 year ago

Sweet, that sounds promising then

TristanGrobler commented 1 year ago

I am sure you are busy, so don't mean to rush you. Do you perhaps have a time frame for releasing package update?

Thanks

tlserver commented 1 year ago

I think the published version is already the most updated version. What do you mean?

TristanGrobler commented 1 year ago

Ok maybe I must just retry. The package size was still about 50mb too large when added to my project. Will let you know.

Thanks again.

On Fri, 03 Mar 2023, 07:09 6y, @.***> wrote:

I think the published version is already the most updated version. What do you mean?

— Reply to this email directly, view it on GitHub https://github.com/tlserver/flutter_map_location_marker/issues/55#issuecomment-1452982914, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQYDL24HOROBECFIZNEU4R3W2F4ITANCNFSM6AAAAAAUXWJKF4 . You are receiving this because you authored the thread.Message ID: @.***>

tlserver commented 1 year ago

How do you get this result? Can you provide details reproduce steps?

TristanGrobler commented 1 year ago

Ok I tested it again and it is nice an small now, so it is resolved. Thanks