Flutter Expert

Automate and integrate Flutter Expert tools for advanced cross-platform mobile development

Flutter Expert is a community skill for building production Flutter applications, covering widget composition, platform channels, performance profiling, custom rendering, and advanced state patterns for experienced Flutter development.

What Is This?

Overview

Flutter Expert provides advanced patterns for building polished Flutter applications. It covers widget composition with custom render objects and layout protocols for specialized UI behavior, platform channel integration for calling native iOS and Android APIs from Dart code, performance profiling with DevTools timeline, memory analysis, and jank detection, custom painting with Canvas API for drawing charts, gauges, and custom visual elements, and advanced state management patterns using code generation, dependency graphs, and computed state derivation. The skill enables experienced Flutter developers to solve complex problems that require understanding of the rendering pipeline and platform integration layer.

Who Should Use This

This skill serves senior Flutter developers building complex custom widgets and interactions, teams integrating native platform features through method channels, and engineers optimizing Flutter application performance for production release.

Why Use It?

Problems It Solves

Standard widgets cannot express every layout and interaction pattern, requiring custom render objects. Accessing device hardware like biometrics, NFC, or platform-specific APIs needs platform channel bridges. Identifying performance bottlenecks in complex widget trees requires systematic profiling. Rendering custom graphics like charts and data visualizations demands Canvas API knowledge.

Core Highlights

Custom render objects implement specialized layout and painting logic beyond standard widgets. Platform channels bridge Dart and native code for device-specific functionality. DevTools profiler identifies frame drops, memory leaks, and rebuild hotspots. Canvas painter creates custom visual elements with paths, gradients, and transforms.

How to Use It?

Basic Usage

import 'package:flutter/services.dart';

class NativeBridge {
  static const _channel =
    MethodChannel('com.app/native');

  static Future<String> getPlatformInfo()
      async {
    final result = await _channel
      .invokeMethod<String>(
        'getPlatformInfo');
    return result ?? 'Unknown';
  }

  static Future<bool> authenticate()
      async {
    final result = await _channel
      .invokeMethod<bool>(
        'authenticate');
    return result ?? false;
  }

  static void listenToEvents(
      void Function(String) callback
  ) {
    const EventChannel(
      'com.app/events',
    ).receiveBroadcastStream()
      .listen((event) {
        callback(event.toString());
      });
  }
}

// Usage
final info = await NativeBridge
  .getPlatformInfo();
print('Platform: $info');

Real-World Examples

import 'dart:math';
import 'package:flutter/material.dart';

class CircularProgress extends
    CustomPainter {
  final double progress;
  final Color color;
  final double strokeWidth;

  CircularProgress({
    required this.progress,
    this.color = Colors.blue,
    this.strokeWidth = 8.0,
  });

  @override
  void paint(
      Canvas canvas, Size size) {
    final center = Offset(
      size.width / 2,
      size.height / 2);
    final radius = (size.width -
      strokeWidth) / 2;

    final bgPaint = Paint()
      ..color = color.withOpacity(0.2)
      ..strokeWidth = strokeWidth
      ..style = PaintingStyle.stroke;
    canvas.drawCircle(
      center, radius, bgPaint);

    final fgPaint = Paint()
      ..color = color
      ..strokeWidth = strokeWidth
      ..style = PaintingStyle.stroke
      ..strokeCap = StrokeCap.round;
    canvas.drawArc(
      Rect.fromCircle(
        center: center,
        radius: radius),
      -pi / 2,
      2 * pi * progress,
      false,
      fgPaint);
  }

  @override
  bool shouldRepaint(
      CircularProgress old) =>
    old.progress != progress;
}

// Usage
CustomPaint(
  size: const Size(100, 100),
  painter: CircularProgress(
    progress: 0.75,
    color: Colors.teal),
)

Advanced Tips

Use RepaintBoundary and shouldRepaint to minimize unnecessary canvas redraws during animation frames. Profile applications with DevTools in profile mode rather than debug mode for accurate performance metrics. Use Isolates for heavy computation to keep the main thread responsive during animation.

When to Use It?

Use Cases

Build a data visualization dashboard with custom chart painters for bar, line, and pie charts. Create a biometric login flow using platform channels to access Face ID and fingerprint APIs. Implement a custom layout widget that arranges children in a radial or spiral pattern.

Related Topics

Flutter rendering pipeline, platform channels, custom painting, performance profiling, and native integration.

Important Notes

Requirements

Flutter SDK with platform-specific development tooling for iOS and Android. Profiling in release or profile mode for accurate performance data. Native language knowledge (Swift/Kotlin) for platform channel implementations.

Usage Recommendations

Do: use profile mode for performance testing since debug mode includes overhead that skews results. Cache Paint objects and Path instances in CustomPainter to avoid allocations during paint calls. Handle platform channel errors with try-catch for graceful fallbacks.

Don't: create custom render objects when existing widgets or CustomPainter can achieve the same result. Block the main isolate with heavy computation during animations. Assume platform channel calls will always succeed without error handling.

Limitations

Custom render objects require deep understanding of the Flutter layout protocol. Platform channels add platform-specific code that must be maintained separately for iOS and Android. Canvas API does not support hardware-accelerated text rendering with the same richness as Text widgets.