yx_scope_flutter 1.0.2 copy "yx_scope_flutter: ^1.0.2" to clipboard
yx_scope_flutter: ^1.0.2 copied to clipboard

An adapter package that provides yx_scope widgets for Flutter UI integration

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:yx_scope/yx_scope.dart' hide ScopeListener;
import 'package:yx_scope_flutter/yx_scope_flutter.dart';

import 'di/app/app_scope.dart';
import 'utils/logger.dart';

Future<void> main() async {
  ScopeObservatory.logger = const Logger();
  runApp(const App());
}

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

  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> {
  final _appScopeHolder = AppScopeHolder();

  @override
  void initState() {
    super.initState();
    _appScopeHolder.create();
  }

  @override
  void dispose() {
    _appScopeHolder.drop();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return ScopeProvider(
      holder: _appScopeHolder,
      child: ScopeBuilder<AppScopeContainer>.withPlaceholder(
        builder: (context, appScope) {
          return MaterialApp.router(
            title: 'YxScopedFlutter Demo',
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            routerDelegate: appScope.routerDelegateDep.get,
          );
        },

        // Shows this widget while [appScopeHolder] is loading
        placeholder: const Center(child: CircularProgressIndicator()),
      ),
    );
  }
}
25
likes
150
points
210
downloads

Publisher

verified publisherdev.go.yandex

Weekly Downloads

An adapter package that provides yx_scope widgets for Flutter UI integration

Repository (GitHub)
View/report issues

Topics

#di #scope #dependency-injection #dependency-management

Documentation

API reference

License

MIT (license)

Dependencies

flutter, yx_scope

More

Packages that depend on yx_scope_flutter