flutterx_starter_kit 0.0.4
flutterx_starter_kit: ^0.0.4 copied to clipboard
A comprehensive starter kit that accelerates Flutter app development with ready-to-use components and best practices, especially for GetX state management.
FlutterX Starter Kit #
[FlutterX Starter Kit]
A comprehensive starter kit that accelerates Flutter app development with ready-to-use components and best practices, especially for GetX state management.
Features #
โ Currently Available #
- ๐ป CLI Helpers - Generate your project fast code fast deploy
- ๐ ApiClient - Powerful HTTP client with complete features
- ๐จ UI Components - Widget library (TextKit)
๐ง Coming Soon #
- ๐ฑ Responsive Utils - Helper for responsive design
- ๐ Logger - Advanced logging system
Installation #
Add this package to your pubspec.yaml:
dependencies:
flutterx_starter_kit: <latest-version>
Or install via command line:
flutter pub add flutterx_starter_kit
Getting Started #
Setup #
Add dependencies flutter_dotenv
flutter pub add flutter_dotenv
Create .env in root folder
API_BASE_URL = www.example-api.com
Add .env to assets
flutter:
assets:
- .env
Don't forget add async in your main()
void main() async {
Initialize ApiClient with CLI #
flutter pub global activate flutterx_starter_kit
Or
dart pub global activate flutterx_starter_kit
And Then:
flutterx init
Initialize ApiClient Manually #
Initialize ApiClient in main() before runApp():
import 'package:flutter/material.dart';
import 'package:flutterx_starter_kit/flutterx_starter_kit.dart';
void main() {
// Initialize API Client
ApiClient.init(ApiConfig(
baseUrl: const String.fromEnvironment(
'API_BASE_URL',
// If API_BASE_URL not setup in env
defaultValue: 'http://10.0.2.2:8080',
),
));
runApp(MyApp());
}
Basic Usage #
import 'package:flutterx_starter_kit/flutterx_starter_kit.dart';
// GET request
final response = await ApiClient.instance.get('/users');
print(response.data); // parsed JSON response
// POST request
final newUser = await ApiClient.instance.post('/users', {
'name': 'John Doe',
'email': 'john@example.com',
});
// PUT request
final updated = await ApiClient.instance.put('/users/1', {
'name': 'Jane Doe',
});
// DELETE request
await ApiClient.instance.delete('/users/1');
Font Usage #
import 'package:flutterx_starter_kit/flutterx_starter_kit.dart';
Initialize
# Font poppins (default)
flutterx init --file lib/main.dart
# Font fredoka
flutterx init --file lib/main.dart --font fredoka
# Font montserrat
flutterx init --file lib/main.dart --font montserrat
๐จ Currently Supported Fonts
| Font Name | Command | Style | Best For |
|---|---|---|---|
| Poppins | --font poppins |
Modern, Geometric | Default, General purpose, UI elements |
| Fredoka | --font fredoka |
Rounded, Friendly | Playful apps, Kids content, Fun branding |
| Roboto | --font roboto |
Neutral, Clean | Material Design, Android apps |
| Montserrat | --font montserrat |
Elegant, Professional | Business apps, Professional content |
| Open Sans | --font opensans |
Humanist, Readable | Long-form content, Articles, Blogs |
| Lato | --font lato |
Warm, Stable | Corporate, Professional websites |
| Nunito | --font nunito |
Rounded, Balanced | Friendly interfaces, Modern apps |
| Raleway | --font raleway |
Elegant, Thin | Fashion, Luxury, Minimalist designs |
| Inter | --font inter |
Modern, Precise | UI/UX, Dashboard, Data-heavy apps |
๐งพ Quick Reference
| Method | Size | Weight | Usage |
|---|---|---|---|
displayLarge |
57 | Light | Splash/Onboarding hero |
displayMedium |
45 | Regular | Main page headline |
displaySmall |
36 | Regular | Sub headline |
headLineLarge |
32 | SemiBold | Page title (AppBar) |
headLineMedium |
28 | SemiBold | Section title |
headLineSmall |
24 | SemiBold | Important subtitle |
titleLarge |
22 | SemiBold | Card/Dialog title |
titleMedium |
16 | Medium | List title |
titleSmall |
14 | Medium | Card subtitle |
bodyLarge |
16 | Regular | Main paragraph |
bodyMedium |
14 | Regular | Secondary text |
bodySmall |
12 | Regular | Caption |
labelLarge |
14 | Medium | Button text |
labelMedium |
12 | Medium | Chip/Small button |
labelSmall |
11 | Regular | Helper/Hint text |
example
import 'package:flutterx_starter_kit/flutterx_starter_kit.dart';
class ExamplePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: TextKit.titleLarge('My App'),
),
body: SingleChildScrollView(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// ===== DISPLAY STYLES =====
TextKit.displayLarge('Hero Text'),
SizedBox(height: 8),
TextKit.displayMedium('Welcome Back!'),
SizedBox(height: 8),
TextKit.displaySmall('Subtitle Hero'),
SizedBox(height: 24),
// ===== HEADLINE STYLES =====
TextKit.headlineLarge('Main Headline'),
SizedBox(height: 8),
TextKit.headlineMedium('Section Title'),
SizedBox(height: 8),
TextKit.headlineSmall('Sub Section'),
SizedBox(height: 24),
// ===== TITLE STYLES =====
TextKit.titleLarge('Card Title'),
SizedBox(height: 8),
TextKit.titleMedium('List Item Title'),
SizedBox(height: 8),
TextKit.titleSmall('Small Title', color: Colors.grey),
SizedBox(height: 24),
// ===== BODY STYLES =====
TextKit.bodyLarge(
'This is the main paragraph text. Lorem ipsum dolor sit amet, '
'consectetur adipiscing elit.',
height: 1.6,
),
SizedBox(height: 8),
TextKit.bodyMedium(
'Secondary description text here.',
color: Colors.grey[700],
),
SizedBox(height: 8),
TextKit.bodySmall(
'Small caption or note text.',
color: Colors.grey[600],
),
SizedBox(height: 24),
// ===== LABEL STYLES (untuk Button, dll) =====
ElevatedButton(
onPressed: () {},
child: TextKit.labelLarge('Button Text'),
),
SizedBox(height: 8),
Chip(
label: TextKit.labelMedium('Chip Label', color: Colors.black),
),
SizedBox(height: 8),
TextKit.labelSmall('Helper text or hint'),
SizedBox(height: 8),
TextKit.bodyLarge(
'Very long text that might overflow...',
maxLines: 2,
overflow: TextOverflow.ellipsis,
color: Colors.blue,
),
TextKit.headlineMedium(
'Centered Title',
align: TextAlign.center,
color: Theme.of(context).primaryColor,
),
TextKit.bodyLarge(
'Paragraph with custom line height for better readability.',
height: 1.8,
color: Colors.black87,
),
],
),
),
);
}
}
Others Example #
//example 1
import 'package:flutter/material.dart';
import 'package:flutterx_starter_kit/flutterx_starter_kit.dart';
String? accessToken = 'xxx123xxx123';
void main() {
ApiClient.init(ApiConfig(
baseUrl: 'https://jsonplaceholder.typicode.com',
tokenProvider: () async => accessToken, // Set global Authorization
));
runApp(MyApp());
}
//example 2
final public = await ApiClient.instance.get('/v1/info',
opts: const ApiRequestOptions(skipAuth: true), // Skip headers
);
//example 3
await ApiClient.instance.get(
'/v1/public-info',
opts: const ApiRequestOptions(
skipAuth: true,
headers: {'X-Trace': 'abc123'}, // Need others headers
),
);
//example 4
ApiClient.init(ApiConfig(baseUrl: 'https://api.example.com'));
// Not set global, need authorization
final res1 = await ApiClient.instance.get(
'/v1/secure-data',
opts: const ApiRequestOptions(
headers: {'Authorization': 'Bearer xxx123xxx123'}, // If not set global, add 'Bearer'
),
);
// Not set global, no needed authorization
final res2 = await ApiClient.instance.get('/v1/public-info');
API Reference #
ApiClient #
Singleton HTTP client for REST API communication.
Static Methods
init(ApiConfig config)- Initialize singleton instanceinstance- Get singleton instance
Instance Methods
- GET request -
get(String endpoint, {Map<String, dynamic>? query, ApiRequestOptions opts}) - POST request -
post(String endpoint, dynamic body, {Map<String, dynamic>? query, ApiRequestOptions opts}) - PUT request -
put(String endpoint, dynamic body, {Map<String, dynamic>? query, ApiRequestOptions opts}) - PATCH request -
patch(String endpoint, dynamic body, {Map<String, dynamic>? query, ApiRequestOptions opts}) - DELETE request -
delete(String endpoint, {Map<String, dynamic>? query, ApiRequestOptions opts, dynamic body})
ApiConfig #
Configuration for ApiClient.
Properties:
baseUrl(String) - API base URL without trailing slashtimeout(Duration) - Request timeout, default 20 secondstokenProvider(TokenProvider?) - Function to get access tokenrefreshToken(RefreshToken?) - Function to refresh token on 401defaultHeaders(DefaultHeadersBuilder?) - Function for global headersonUnauthorized(OnUnauthorized?) - Callback when unauthorizedhttpClient(http.Client?) - Custom HTTP client
ApiRequestOptions #
Per-request options to override global configuration.
Properties:
baseUrl(String?) - Override base URL for this requestheaders(Map<String, String>?) - Additional/override headersskipAuth(bool) - Skip Authorization header, default falsequery(Map<String, dynamic>?) - Query parameters
ApiResponse<T> #
Response wrapper from HTTP request.
Properties:
statusCode(int) - HTTP status codedata(T?) - Parsed response body (JSON โ Map/List)headers(Map<String, String>) - Response headers
Exceptions #
ApiException
Exception for HTTP errors (4xx, 5xx).
Properties:
statusCode(int?) - HTTP status codemessage(String) - Error messagedata(dynamic) - Response body
Platform Support #
| Android | iOS | MacOS | Web |
|---|---|---|---|
| โ | โ | โ | โ |
Requirements #
- Flutter:
>=1.17.0 - Dart:
>=3.9.0
Examples #
See the /example folder for complete usage examples of this package.
Additional Information #
Contributing #
Contributions are welcome for everyone!
Issues and Feedback #
If you find a bug or have a feature suggestion:
- ๐ Report bugs
- ๐ก Request features
- ๐ฌ Ask questions
Roadmap #
- โ UI Components (Button, Card, TextField, etc.)
- โ Responsive utilities
- โ Theme management
- โ Navigation utilities
- โ Advanced logging system
- โ Performance monitoring
Changelog #
See CHANGELOG.md for version history.
License #
This package is licensed under the MIT License.
Author #
Ramadhan Hadiatma
- GitHub: @ramadhanhadiatmaa
- Repository: flutterx_starter_kit
Support #
If this package helps you, consider:
- โญ Star the repository on GitHub
- ๐ Like the package on pub.dev
- ๐ข Share with other Flutter developers
Made with โค๏ธ by Ramadhan Hadiatma