vortex 0.0.2 copy "vortex: ^0.0.2" to clipboard
vortex: ^0.0.2 copied to clipboard

Vortex is a first powerful Flutter framework that brings the convenience and structure of Nuxt.js to Flutter development.

example/lib/main.dart

import 'dart:io';

import 'package:example/middleware/auth_middleware.dart';
import 'package:flutter/material.dart';
import 'package:flutterwind_core/flutterwind.dart';
import 'package:vortex/vortex.dart';

void main() async {
  await VortexRouter.discoverRoutes(
    projectDirectory: Directory(Directory.current.path),
  );

  MiddlewareRegistry.register('auth', AuthMiddleware());
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with CompositionMixin {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    final isDarkMode = useRef<bool>('isDarkMode', false);

    // Set up watchers
    watch(isDarkMode, () => isDarkMode.value, (newValue, oldValue) {
      Log.i(
        'Theme changed from ${oldValue! ? "dark" : "light"} to ${newValue ? "dark" : "light"}',
      );
    });

    // Set up lifecycle hooks
    onMounted(() {
      Log.i('App mounted');
    });

    return Vortex(
      child: FlutterWind(
        child: MaterialApp(
          title: 'Vortex Demo',
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
            useMaterial3: true,
            brightness: Brightness.light,
          ),
          darkTheme: ThemeData(
            colorScheme: ColorScheme.fromSeed(
              seedColor: Colors.deepPurple,
              brightness: Brightness.dark,
            ),
            useMaterial3: true,
            brightness: Brightness.dark,
          ),
          themeMode: isDarkMode.value ? ThemeMode.dark : ThemeMode.light,
          initialRoute: '/',
          onGenerateInitialRoutes:
              (initialRoute) => [
                VortexRouter.initialRouteHandler(
                  RouteSettings(name: initialRoute),
                ),
              ],
          onGenerateRoute: VortexRouter.onGenerateRoute,
        ),
      ),
    );
  }
}
2
likes
0
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

Vortex is a first powerful Flutter framework that brings the convenience and structure of Nuxt.js to Flutter development.

Homepage
Repository (GitHub)
View/report issues

Topics

#vortex #nuxt #flutter #build-system

Documentation

Documentation

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

args, flutter, logger, meta, path

More

Packages that depend on vortex