1600+ lines of performance optimization mastery - profiling, rendering, memory, network, battery, APK size with production-ready code examples.
Provides Flutter performance optimization techniques for rendering, memory, and network efficiency, triggered when analyzing slow UI or building production apps.
/plugin marketplace add pluginagentmarketplace/custom-plugin-flutter/plugin install custom-plugin-flutter@pluginagentmarketplace-flutterThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/performance_config.yamlreferences/PERFORMANCE_GUIDE.mdscripts/perf_analyzer.py// 1. Use const constructors
const SizedBox(height: 16);
// 2. Extract widgets for rebuild optimization
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
const Title(), // Const - won't rebuild
BuildCounter(), // Rebuilds only when needed
],
);
}
}
// 3. Use ListView.builder
ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) => ItemTile(item: items[index]),
)
// 4. Cache network images
CachedNetworkImage(imageUrl: 'https://example.com/image.png')
// 5. Use RepaintBoundary for expensive widgets
RepaintBoundary(child: ExpensiveChart())
// 6. Profile regularly
// - Open DevTools Performance tab
// - Record timeline
// - Check frame rate and rebuild counts
// 7. Use const everywhere
const AppBar(title: Text('Title'))
// 8. Profile memory
// - Open DevTools Memory tab
// - Take heap snapshots
// - Look for memory leaks
// 9. Use SingleChildScrollView wisely
SingleChildScrollView(
child: Column(children: [...]),
)
// 10. Optimize images
Image.asset(
'assets/image.png',
cacheHeight: 500,
cacheWidth: 500,
)
Frame Analysis:
// Monitor frame rate with DevTools
// Target: 60 FPS (16.67ms per frame)
// Warning: 30-60 FPS (16-33ms)
// Danger: <30 FPS (>33ms)
class PerformanceMonitor {
void measureFrame() {
final start = DateTime.now();
// Do work
final duration = DateTime.now().difference(start);
print('Frame took ${duration.inMilliseconds}ms');
}
}
Preventing Jank:
// Bad: Expensive computation on main thread
class BadWidget extends StatefulWidget {
@override
State<BadWidget> createState() => _BadWidgetState();
}
class _BadWidgetState extends State<BadWidget> {
@override
Widget build(BuildContext context) {
final expensive = expensiveComputation(); // Blocks UI!
return Text('Result: $expensive');
}
}
// Good: Use Isolate or async
class GoodWidget extends StatefulWidget {
@override
State<GoodWidget> createState() => _GoodWidgetState();
}
class _GoodWidgetState extends State<GoodWidget> {
late Future<dynamic> _computation;
@override
void initState() {
super.initState();
_computation = compute(expensiveComputation, null);
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: _computation,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text('Result: ${snapshot.data}');
}
return CircularProgressIndicator();
},
);
}
}
// Memory profiling with DevTools
// Target: <100MB for typical app
// Peak: <150MB during heavy operations
class MemoryOptimized {
// Bad: Keep large objects in memory
List<LargeObject> _cache = [];
// Good: Limited cache size
final _cache = LimitedQueue<LargeObject>(maxSize: 50);
void dispose() {
_cache.clear();
}
}
class LimitedQueue<T> {
final int maxSize;
final _queue = <T>[];
LimitedQueue({required this.maxSize});
void add(T item) {
_queue.add(item);
if (_queue.length > maxSize) {
_queue.removeAt(0);
}
}
void clear() => _queue.clear();
}
Build with size analysis:
# Android - analyze size
flutter build apk --release --analyze-size
# iOS - check build size
ls -lh build/ios/Release-iphoneos/app.ipa
Reduce size:
// android/app/build.gradle
android {
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
// Split APKs by ABI
flutter build apk --split-per-abi
// Connection pooling with Dio
final dio = Dio(BaseOptions(
connectTimeout: Duration(seconds: 10),
));
// Cache responses
dio.interceptors.add(
CacheInterceptor(
options: CacheOptions(
store: MemoryCacheStore(),
policy: CachePolicy.request,
maxStale: Duration(days: 7),
),
),
);
// Batch requests
Future<(UserList, PostList)> fetchUserAndPosts(String userId) async {
final futures = await Future.wait([
dio.get('/users/$userId'),
dio.get('/posts?userId=$userId'),
]);
return (
UserList.fromJson(futures[0].data),
PostList.fromJson(futures[1].data),
);
}
Build lightning-fast, efficient Flutter apps.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.