الانتقال إلى المحتوى
تطبيقات الموبايلFlutter· 8 دقائق للقراءة

Flutter Doesn't Wrap Native Widgets: It Draws Every Pixel Itself

Your Switch never becomes a UISwitch: Flutter paints the whole UI itself and only borrows a surface from the OS.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
  • Flutter 3.x
محتويات المقال

Two days before release, the iOS tester attaches a screenshot to a ticket: "The notifications toggle on iPhone looks like Android." The developer who built the screen is sure it's a Flutter bug, because Switch is supposed to become a UISwitch on iOS. It never was. On the iPhone, that toggle is exactly what it is on a Pixel: shapes Flutter painted itself, with no native switch anywhere in the app.

The common misconception

The belief goes like this: Flutter is a translation layer. You write Switch, TextField and ListView, and at runtime Flutter maps each widget to the platform's own control, a UISwitch on iOS and an Android switch on Android. The OS draws your UI; Flutter only tells it what to show.

It's a reasonable guess. Flutter's own architecture overview notes that cross-platform frameworks typically work exactly that way, as a layer over the native Android and iOS UI libraries. Flutter apps are called native too, and in release they really are compiled to machine code. On an iPhone, a Flutter app scrolls with iOS physics and uses the San Francisco font, so it feels like iOS did the work. And you can embed real native views. All true, and none of it makes your widgets native controls.

What actually happens

In the docs' words, Flutter "has its own implementations of each UI control, rather than deferring to those provided by the system". The OS gives Flutter a place to draw and forwards touches, keys and accessibility requests. Everything inside that rectangle is Flutter's work.

Three layers, one canvas

Flutter is built as layers, each depending on the one below it:

  • Framework (Dart): widgets, layout, painting, gestures, and the Material and Cupertino libraries. This is the code you write against.
  • Engine (mostly C++): the Dart runtime, text layout and the renderer that rasterizes every frame. The framework talks to it through dart:ui.
  • Embedder (one per platform): starts the app, sets up threads, hands the engine a rendering surface and connects it to the OS for input and accessibility.

On Android, the whole Flutter UI of a typical app is displayed by one FlutterView, which the engine paints into a SurfaceView or a SurfaceTexture. Your hundred widgets aren't a hundred Android views. They're pixels in one.

From a widget to pixels

When a frame is needed, the framework builds your widgets into elements, creates or updates the render objects behind them, lays those out, and calls their paint() methods. The result is a scene of drawing commands, not a set of views. The engine then rasterizes that scene on the GPU with , which precompiles its shaders when the engine itself is built, so they don't compile while your app runs.

Which renderer runs depends on the platform, and the docs are precise about it:

  • iOS: Impeller is the only supported renderer, with no way to switch back to Skia.
  • Android: Impeller is the default on API 29 and later. On older versions, or devices without Vulkan, it falls back to the legacy OpenGL renderer.
  • macOS, Windows and Linux: Impeller is enabled by default as of Flutter 3.47.
  • Web: Flutter uses Skia today.

"Native" means native code, not native widgets

In release builds, your Dart code is compiled to ARM or x64 machine code, so "native" is fair when it comes to speed. Platform APIs like the camera are reached through a that calls Kotlin or Swift code, which is how most plugins work. The iOS feel is Flutter's work too: it reimplements page transitions, scroll physics, fonts and text selection, and adapts them to the platform automatically. Which control to show, though, is a design decision, and that one is yours.

Why the toggle looked like Android

Switch is a Material widget, and it paints a Material switch on every platform. If you want each platform's convention, you have to ask for it:

Dart notify_tile.dart
import 'package:flutter/material.dart';class NotifyTile extends StatelessWidget {  const NotifyTile({super.key, required this.on, required this.onChanged});  final bool on;  final ValueChanged<bool> onChanged;  @override  Widget build(BuildContext context) {    return ListTile(      title: const Text('Notifications'),      // A Material switch on every platform, iPhone included      trailing: Switch(value: on, onChanged: onChanged),    );  }}

Switch.adaptive checks the theme's platform: on iOS and macOS it looks and feels like the iOS control, elsewhere it's the Material one. Both are drawn by Flutter. The Cupertino library implements the iOS design language with Flutter's own widgets; it isn't a bridge to UIKit. Slider, Checkbox, Radio, CircularProgressIndicator, RefreshIndicator and AlertDialog have adaptive constructors too.

When you really need a native view

Some UI is impractical to rebuild: a map SDK, a web view, a native ad. For those, Flutter has : AndroidView and UiKitView embed a real native view inside the Flutter UI.

Dart native_map.dart
import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';// 'native-map' must be registered by your Android and iOS host codeclass NativeMap extends StatelessWidget {  const NativeMap({super.key});  @override  Widget build(BuildContext context) {    return switch (defaultTargetPlatform) {      TargetPlatform.android => const AndroidView(viewType: 'native-map'),      TargetPlatform.iOS => const UiKitView(viewType: 'native-map'),      _ => const Center(child: Text('Map not available here')),    };  }}
MythReality
Switch becomes a UISwitch on iOSIt paints a Material switch everywhere; Switch.adaptive paints an iOS-style one on iOS and macOS
The OS draws your UIFlutter paints a scene, and the engine rasterizes it into a surface the embedder provides
"Native" means native widgetsIt means machine code in release, plus platform channels for native APIs
An iOS feel needs iOS controlsFlutter reimplements transitions, scroll physics, fonts and text selection per platform
Native views mix in for freePlatform views add sync overhead and are worth it only where rebuilding isn't practical

How to apply it in your project

  1. Choose a look per control, on purposeDecide between Material everywhere, Cupertino everywhere, or .adaptive constructors. For input controls like switches, sliders and dialogs, the docs recommend following each platform's conventions, which .adaptive gives you for free.
  2. Review both platforms from the first screenDon't assume a widget will "look native" on its own. Check every new screen on an iPhone and an Android phone, or at least with the ThemeData.platform trick during development.
  3. Reach for plugins before platform viewsCamera, location and payments are platform APIs, not UI: a plugin reaches them through platform channels, no native view needed. Embed a native view only when the UI itself can't be rebuilt, then profile scrolling on a low-end Android phone.
  4. Isolate rendering bugs before reporting themIf something renders wrong on Android, run flutter run --no-enable-impeller once. If the glitch disappears, it's tied to the renderer, and that's exactly what to put in the bug report.

Key takeaways

  • Flutter doesn't map widgets to native controls: its framework paints the whole UI and the engine rasterizes it.
  • Impeller renders on iOS and on Android API 29+ (older or non-Vulkan devices fall back to OpenGL); the web uses Skia.
  • "Native" refers to compiled machine code and to platform channels, not to the widgets you see.
  • A platform's look is your choice: Material, Cupertino or .adaptive, all drawn by Flutter.
  • Use platform views only for native UI you can't reasonably rebuild, and measure what they cost.

📚 المصادر

  1. Flutter architectural overview — Flutter docs
  2. Impeller rendering engine — Flutter docs
  3. Hosting native Android views in your Flutter app with platform views — Flutter docs
  4. Automatic platform adaptations — Flutter docs

التعليقات (0)