stacked_services 1.0.4 copy "stacked_services: ^1.0.4" to clipboard
stacked_services: ^1.0.4 copied to clipboard

A package that contains some default implementations of services required for a cleaner implementation of the Stacked Architecture.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:stacked_services/stacked_services.dart';
import 'package:stacked_services_example/app/app.locator.dart';
import 'package:stacked_services_example/app/app.router.dart';
import 'package:stacked_services_example/ui/setup_bottom_sheet_ui.dart';
import 'package:stacked_services_example/ui/setup_dialog_ui.dart';
import 'package:stacked_services_example/ui/setup_snackbar_ui.dart';

void main() {
  setupLocator();
  setupDialogUi();
  setupSnackbarUi();
  setupBottomSheetUi();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Stacked Services Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      navigatorObservers: [
        StackedService.routeObserver,
        _LoggingObserver(),
      ],
      onGenerateRoute: StackedRouter().onGenerateRoute,
      navigatorKey: StackedService.navigatorKey,
    );
  }
}

class _LoggingObserver extends NavigatorObserver {
  @override
  void didPop(Route route, Route? previousRoute) {
    print(
        'route.name: ${route.settings.name}, previousRoute.name: ${previousRoute?.settings.name}');
    super.didPop(route, previousRoute);
  }

  @override
  void didRemove(Route route, Route? previousRoute) {
    print(
        'route.name: ${route.settings.name}, previousRoute.name: ${previousRoute?.settings.name}');
    super.didRemove(route, previousRoute);
  }

  @override
  void didPush(Route route, Route? previousRoute) {
    print(
        'route.name: ${route.settings.name}, previousRoute.name: ${previousRoute?.settings.name}');
    super.didPush(route, previousRoute);
  }

  @override
  void didReplace({Route? newRoute, Route? oldRoute}) {
    print(
        'newRoute.name: ${newRoute?.settings.name}, oldRoute.name: ${oldRoute?.settings.name}');
    super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
  }
}
275
likes
0
pub points
98%
popularity

Publisher

verified publisherfilledstacks.com

A package that contains some default implementations of services required for a cleaner implementation of the Stacked Architecture.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto, flutter, get, stacked, stacked_shared

More

Packages that depend on stacked_services