Skip links

Using Native Code alongside Flutter: How to decide?

Flutter is a powerful cross-platform UI toolkit that can be used to develop high-quality mobile apps for Android and iOS from a single codebase. However, there are some cases where you may need to use native code alongside Flutter.
In this guide, we will discuss the reasons why you might need to use native code alongside Flutter, the different ways to do it, and the best practices to follow. We will also cover some of the challenges that you may face when using native code alongside Flutter and how to overcome them.

By the end of this guide, you will have a deep understanding of how to use native code alongside Flutter to create high-quality mobile apps.

Here are some of the things that we will cover in this guide:

  • The reasons why you might need to use native code alongside Flutter
  • The different ways to use native code alongside Flutter
  • The best practices for using native code alongside Flutter
  • The challenges that you may face when using native code alongside Flutter
  • How to overcome the challenges of using native code alongside Flutter


So whether you are a beginner or an experienced Flutter developer, this guide is for you. We will start with the basics and then go into more detail as we progress. By the end of this guide, you will be an expert in using native code alongside Flutter.

Using Native Code alongside Flutter


Flutter is a powerful cross-platform UI toolkit that can be used to develop high-quality mobile apps for Android and iOS from a single codebase. However, there are some cases where you may need to use native code alongside Flutter.

Here are some of the reasons why you might want to use native code alongside Flutter:

  • To access native APIs: Some APIs are only available in native code. For example, if you need to access the camera or the file system, you will need to use native code.
  • To improve performance: In some cases, native code can be faster than Flutter code. This is especially true for computationally intensive tasks, such as image processing or video decoding.
  • To customize the UI: Flutter provides a wide range of widgets, but you may need to customize the UI using native code. For example, you may need to use native code to create a custom animation or to integrate with a third-party library.

There are a few ways to use native code alongside Flutter:

  • Use a platform-specific plugin: There are many platform-specific plugins available for Flutter. These plugins allow you to access native APIs and features from Flutter code.
  • Write native code in a separate file: You can also write native code in a separate file and then call it from Flutter code. This can be useful if you need to access a native API that is not available in a plugin.
  • Use a hybrid framework: A hybrid framework is a framework that combines native code with a cross-platform UI toolkit. This can be a good option if you need to access native APIs and features, but you also want to take advantage of the benefits of a cross-platform UI toolkit.

The best way to use native code alongside Flutter will depend on your specific needs. If you only need to access a few native APIs, then using a plugin is a good option. If you need to access a wider range of native APIs or if you need to customize the UI, then writing native code in a separate file or using a hybrid framework may be a better option.

What are the drawbacks / limitations of using native code alongside Flutter?:

  • It can make the development process more complex. When you use native code alongside Flutter, you need to manage two codebases: the Flutter codebase and the native codebase. This can make the development process more complex and time-consuming.
  • It can make the app more difficult to maintain. If you need to make changes to the native code, you need to make sure that the changes are also made to the Flutter codebase. This can make the app more difficult to maintain.
  • It can make the app less portable. If you use native code that is specific to a particular platform, your app will not be as portable. This means that you will need to create separate native code for each platform that you want to support.


Despite these caveats, there are some cases where using native code alongside Flutter can be a good option. For example, if you need to access a native API that is not available in Flutter, or if you need to improve the performance of your app, then using native code may be the best solution.

Some examples of specific APIs that need native code for best performance:

Hardware-intensive APIs

  • Camera: The camera API is a hardware-intensive API that can be difficult to get good performance with Flutter. Using native code can help with the performance of the camera API.
  • Location: The location API is also a hardware-intensive API that can be difficult to get good performance with Flutter. Using native code can help to improve the performance of the location API.

Lightweight APIs

  • Contacts: The contacts API is a relatively lightweight API, but it can still be difficult to get good performance with Flutter. Using native code, the performance of the contacts API could be increased.
  • File system: The file system API is a relatively lightweight API, but it can still be difficult to get good performance with Flutter. Using native code can help to improve the performance of the file system API.
  • Notification: The notification API is a relatively lightweight API, but it can still be difficult to get good performance with Flutter.

Final Thoughts

In this blog post, we have discussed the top platform-specific APIs that are mostly used with Flutter and native code. We have also discussed the APIs that do not work well with Flutter and need native code for best performance.

If you are using any of the APIs that we have discussed in your Flutter app, it is important to benchmark the performance and see if you are getting the results that you need. If not, you may need to use native code to improve the performance.

We hope this blog post has been helpful. If you have any questions, please feel free to book a meeting with us. We would be happy to discuss your specific needs and help you create a high-performance mobile app. Book a Meeting with our Flutter Solution Experts.