Skip to content

[Bug]: Instance not created, create with createInstance() #308

@tentenponce

Description

@tentenponce

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

destroy() in FlutterEngine is being called in this library: https://pub.dev/packages/flutter_foreground_task when foreground service is stopped. When this happens, calling any function from GoogleMapsNavigator (example: GoogleMapsNavigator.areTermsAccepted()) returns error: Instance not created, create with createInstance().

Is this an expected scenario, if yes, then what are the possible workarounds (or better if proper solution), and if no, then what should be the fix that needs to be applied on flutter-navigation-sdk?

Flutter version

3.27.2

Package version

0.5.1

Native SDK versions

  • I haven't changed the version of the native SDKs

Flutter Doctor Output

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.2, on macOS 15.3.1 24D70 darwin-arm64, locale en-PH)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.
[!] Xcode - develop for iOS and macOS (Xcode 16.1)
    ! iOS 18.1 Simulator not installed; this may be necessary for iOS and macOS development.
      To download and install the platform, open Xcode, select Xcode > Settings > Components,
      and click the GET button for the required platform.

      For more information, please visit:
        https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.98.1)
[✓] Connected device (5 available)
[✓] Network resources

! Doctor found issues in 2 categories.

Steps to reproduce

  1. Call FlutterEngine(context).destroy() on Android native code
  2. Call any function from GoogleMapsNavigator (example: GoogleMapsNavigator.areTermsAccepted())

Expected vs Actual Behavior

SDK should work properly even if other SDK calls destroy() on FlutterEngine

Code Sample

MainActivity.kt - simply add FlutterEngine(this).destroy(), you can make this button trigger, add delay, etc

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    FlutterEngine(this).destroy()
}

then call any function from GoogleMapsNavigator

Additional Context

No response

Metadata

Metadata

Assignees

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions