Leverage AI as Flutter Devs to Code Apps 5x Faster

Samyak Jain
CommandDash
Published in
4 min readApr 6, 2023

--

During the journey of building Welltested AI — World’s First AI Testing Autopilot for Flutter, I came across some really cool tools and prompts that can help you write code 5x faster with better quality.

Let’s go!

1. CodeGPT

CodeGPT is a VS Code extension that is directly integrated with gpt-3.5-turbo and gpt-4 APIs so we don’t have to go through the hassle of copy-pasting code between ChatGPT and our IDE.

It comes with inbuilt functions like

  1. Explain Selection
  2. Refactor Selection
  3. Find Problems
  4. Optimize Selection
  5. Write Documentation

2. ChatGPT Prompts

a. Generating Boilerplate Code

One of the most time-consuming aspects of app development is writing boilerplate code. AI tools like ChatGPT can help generate code snippets for repository classes, API calls, and Firestore requests. For example, you can provide a prompt like:

To generate:


import 'dart:convert';
import 'package:http/http.dart' as http;

class AuthenticationRepository {
final String _baseUrl = 'https://example.com/api';

Future<String> authenticate(String username, String password) async {
final String apiUrl = '$_baseUrl/login';

final response = await http.post(
apiUrl,
headers: {'Content-Type': 'application/json'},
body: jsonEncode({'username': username, 'password': password}),
);

if (response.statusCode == 200) {
final Map<String, dynamic> responseData = jsonDecode(response.body);
final String authToken = responseData['auth_token'];
return authToken;
} else {
throw Exception('Failed to authenticate user');
}
}
}

b. Crafting Classes from a list of draft function

Simply provide a prompt that includes the function names, return types, and comments describing what they should do. For instance:

ChatGPT will generate the code for the authentication class, including the necessary function implementations.

import 'package:firebase_auth/firebase_auth.dart';

class Authentication {
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;

Future<void> signUp(String email, String password) async {
try {
await _firebaseAuth.createUserWithEmailAndPassword(
email: email, password: password);
} catch (e) {
print('Error: $e');
}
}

Future<void> signIn(String email, String password) async {
try {
await _firebaseAuth.signInWithEmailAndPassword(
email: email, password: password);
} catch (e) {
print('Error: $e');
}
}

Future<void> signOut() async {
try {
await _firebaseAuth.signOut();
} catch (e) {
print('Error: $e');
}
}
}

c. Creating animation experiences

Animations can bring a wow factor to any mobile app but they’re generally difficult to get right.

Prompting GPT4 (yes, we need an expert here):

We were able to get plausible code which we tweaked a bit to match our design like a charm.

d. Few shots learning.

It’s hard to imagine how a language-focused model can code visual widgets for us. But ChatGPT is a wizard that can do a lot of things if we give it the right examples to learn from.

3. Galileo AI

Galileo AI acts as your Figma designer and creates delightful, editable UI designs from a simple text description. The product sounds promising but I’ve been on the waiting list for more than a month now and haven’t tried it first-hand yet.

4. FlutterFlow AI Gen

FlutterFlow AI gen takes it a step ahead and provides us with beautifully generated screens right from a prompt.

5. Welltested AI

Welltested AI is a Flutter-first testing AI that helps you add and maintain unit tests for your codebase and deliver welltested apps to your users.

It works just by adding @Welltested annotation to your classes and generates exhaustive test cases covering different edge cases within minutes.

In conclusion, we are truly experiencing a thrilling era. When utilized effectively, AI has the potential to boost our productivity fivefold, potentially leading to a mere 8-hour work week (not a day). Embrace the future!

--

--

Samyak Jain
CommandDash

Building for Flutter | Helping devs build welltested apps