fluent_sdk 0.2.2 copy "fluent_sdk: ^0.2.2" to clipboard
fluent_sdk: ^0.2.2 copied to clipboard

Package that provide a way to modularize features through a service locator.

fluent_sdk #

Package that provide a way to modularize features through a service locator.

Getting Started #

Add dependencies #

fluent_sdk: ^0.2.2

Create a interface/implementation to access the feature functionalities #

// Interface
abstract class HomeApi {
  Widget getHomePage();
}

// Implementation
class HomeApiImpl extends HomeApi {
  @override
  Widget getHomePage() {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Fluent SDK Demo"),
      ),
      body: const Center(
        child: Text("Hello from Fluent SDK"),
      ),
    );
  }
}

Create module #

class HomeModule extends Module {

  @override
  Future<void> build(Registry registry) async {
    // Register home api to access globally to it
    registry.registerSingleton<HomeApi>((it) => HomeApiImpl());
  }
}

Build module #

void main() async {
  await Fluent.build([
    HomeModule(),
  ]);

  runApp(const MainApp());
}

Use it #

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    // Access to home api and get home page
    final homePage = Fluent.get<HomeApi>().getHomePage();

    return MaterialApp(
      home: Scaffold(
        body: homePage,
      ),
    );
  }
}

Example #

0
likes
150
points
378
downloads

Publisher

unverified uploader

Weekly Downloads

Package that provide a way to modularize features through a service locator.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

get_it

More

Packages that depend on fluent_sdk