Repository: flutter
Issue: support tree-shaking native assets when no used dart code references it
Labels: tool,dependency: dart,a: build,has reproducible steps,P2,found in release: 3.10,team-tool,triaged-tool,found in release: 3.13,dependency:dart-triaged

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

When building a project which includes a dependency having a native .so library linked via dart:ffi, it will be included in the resulting build even thou calls to that library were removed by tree-shaking dart code.



### Expected results

libaudioplayers_linux_plugin.so library is not in the package

### Actual results

libaudioplayers_linux_plugin.so library is in the package

### Code sample

<details><summary>Code sample</summary>

```dart


import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:audioplayers/audioplayers.dart';

import 'constants.dart';

class MyApp extends StatefulWidget {
  HomePage createState() => HomePage();
}

const enableAudioplayer = false;

class HomePage extends State<MyApp> {
  late var loop;

  @override
  void initState() {
    super.initState();
    // loop.ap.play(AssetSource("sound/happy_loop.mp3"));
    if (enableAudioplayer) {
      initAudioplayer();
    }
  }

  void initAudioplayer() {
    loop = AudioPlayer();
    // loop = Mgr();
    loop.setReleaseMode(ReleaseMode.loop);
    loop.play(AssetSource("sound/test.mp3"));
    loop.setVolume(0.5);
  }

  @override
  Widget build(BuildContext context) {
    return Stack();
  }
}



```

</details>


### Screenshots or Video

_No response_

### Logs

<details><summary>Logs</summary>

```console
[ +544 ms] [6/10] Building CXX object plugins/audioplayers_linux/CMakeFiles/audioplayers_linux_plugin.dir/audio_player.cc.o
[ +309 ms] [7/10] Building CXX object plugins/audioplayers_linux/CMakeFiles/audioplayers_linux_plugin.dir/audioplayers_linux_plugin.cc.o
[ +134 ms] [8/10] Linking CXX shared library plugins/audioplayers_linux/libaudioplayers_linux_plugin.so
[ +196 ms] [9/10] Linking CXX executable intermediates_do_not_run/testapp
[        ] [9/10] Install the project...
[  +12 ms] -- Install configuration: "Release"
[   +8 ms] -- Installing: /home/make/testapp/build/linux/x64/release/bundle/testapp
[        ] -- Set runtime path of "/home/make/testapp/build/linux/x64/release/bundle/testapp" to "$ORIGIN/lib"
[        ] -- Installing: /home/make/testapp/build/linux/x64/release/bundle/data/icudtl.dat
[   +2 ms] -- Installing: /home/make/testapp/build/linux/x64/release/bundle/lib/libflutter_linux_gtk.so
[  +40 ms] -- Installing: /home/make/testapp/build/linux/x64/release/bundle/lib/libaudioplayers_linux_plugin.so
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel beta, 3.11.0-0.1.pre, on Debian GNU/Linux bookworm/sid 5.10.0-13-amd64, locale en_US.UTF-8)
    • Flutter version 3.11.0-0.1.pre on channel beta at /home/make/dev-tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 350d2c3a6c (8 weeks ago), 2023-05-23 15:52:05 -0700
    • Engine revision 7eca5cd1c5
    • Dart version 3.1.0 (build 3.1.0-63.1.beta)
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/make/AndroidSDK/
    • Platform android-33, build-tools 30.0.3
    • Java binary at: /snap/android-studio/125/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Debian clang version 14.0.6
    • cmake version 3.25.1
    • ninja version 1.11.1
    • pkg-config version 1.8.0

[✓] Android Studio (version 2021.3)
    • Android Studio at /snap/android-studio/125/android-studio
    • Flutter plugin version 72.1.1
    • Dart plugin version 213.7433
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Debian GNU/Linux bookworm/sid 5.10.0-13-amd64
    • Chrome (web)    • chrome • web-javascript • Chromium 108.0.5359.124 built on Debian bookworm/sid, running on Debian bookworm/sid

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>