Vortex is a powerful Flutter framework that brings the convenience and structure of Nuxt.js to Flutter development. It provides automatic routing, component management, plugin architecture, and more to streamline your Flutter development workflow.
- π File-based Routing: Automatically generate routes based on your file structure in the pages directory
- π§Ή Component System: Create and register reusable components with a simple API
- π Plugin Architecture: Extend functionality with a flexible plugin system
- β‘ Reactive State Management: Built-in reactive state management solution
- π Middleware Support: Add middleware to handle navigation and requests
- π οΈ CLI Tools: Command-line tools for generating pages, components, and more
- Installation
- Basic Setup
- Routing
- Components
- State Management
- Plugins
- Middleware
- CLI Commands
- Examples
- Contributing
- License
Add Vortex to your pubspec.yaml
:
dependencies:
vortex: ^0.0.1
Run flutter pub get
to install the package.
Initialize Vortex in your main.dart
:
import 'package:flutter/material.dart';
import 'package:vortex/vortex.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Vortex.initialize();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Vortex(
child: MaterialApp(
title: 'Vortex App',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
onGenerateRoute: VortexRouter.onGenerateRoute,
initialRoute: '/',
),
);
}
}
Create a new Vortex project with the CLI:
flutter pub run vortex create --name=my_app
This will create a new Flutter project with the Vortex folder structure:
lib/
βββ pages/ # Route pages
βββ components/ # Reusable UI components
βββ layouts/ # Page layouts
βββ middleware/ # Navigation middleware
βββ plugins/ # App plugins
βββ store/ # State management
βββ assets/ # Images, fonts, etc.
βββ generated/ # Auto-generated code
Vortex uses a file-based routing system similar to Nuxt.js.
lib/pages/index.dart β /
lib/pages/about.dart β /about
lib/pages/contact.dart β /contact
lib/pages/users/index.dart β /users
lib/pages/users/profile.dart β /users/profile
lib/pages/users/[id].dart β /users/:id
lib/pages/blog/[...slug].dart β /blog/* (catch-all route)
import 'package:flutter/material.dart';
import 'package:vortex/vortex.dart';
@VortexPage('/about')
class AboutPage extends StatelessWidget {
const AboutPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('About')),
body: const Center(child: Text('About Page')),
);
}
}
flutter pub run vortex page --name=contact --type=stateless
@VortexPage('/users/:id')
class UserDetailPage extends StatelessWidget {
const UserDetailPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final params = VortexRouter.of(context).params;
final userId = params['id'] ?? 'unknown';
return Scaffold(
appBar: AppBar(title: Text('User $userId')),
body: Center(child: Text('User ID: $userId')),
);
}
}
Vortex provides a component system that allows you to create reusable UI components.
// lib/components/button.dart
import 'package:flutter/material.dart';
import 'package:vortex/vortex.dart';
@Component('Button')
class Button extends StatelessWidget {
final String text;
final VoidCallback onPressed;
final Color? color;
const Button({
Key? key,
required this.text,
required this.onPressed,
this.color,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onPressed,
style: color != null ? ElevatedButton.styleFrom(backgroundColor: color) : null,
child: Text(text),
);
}
}
flutter pub run vortex components
context.component('Button')({
'text': 'Click Me',
'onPressed': () => print('Button clicked'),
'color': Colors.blue,
})
import 'package:vortex/vortex.dart';
class CounterState {
final int count;
CounterState({this.count = 0});
CounterState copyWith({int? count}) {
return CounterState(count: count ?? this.count);
}
}
final counterStore = ReactiveStore<CounterState>(CounterState());
void increment() => counterStore.update((state) => state.copyWith(count: state.count + 1));
void decrement() => counterStore.update((state) => state.copyWith(count: state.count - 1));
ReactiveBuilder<CounterState>(
store: counterStore,
builder: (context, state) {
return Text('Count: ${state.count}');
},
)
Coming soon.
Coming soon.
vortex create
- Create new Vortex projectvortex page
- Generate new pagevortex component
- Generate new component
Coming soon.
Pull requests welcome! For major changes, please open an issue first to discuss what you would like to change.
MIT License.
Made with β€οΈ by the Vortex team and CodeSyncr.