Giter Site home page Giter Site logo

weaze-id / witt Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 354 KB

Simple state management powered by ValueNotifier and InheritedWidget

Home Page: https://pub.dev/packages/witt

License: MIT License

Dart 17.88% Kotlin 0.32% Swift 3.78% Objective-C 0.10% CMake 26.22% C++ 49.77% C 1.92%
flutter dart state-management depedency-injection

witt's Introduction

Witt

Simple state management powered by ValueNotifier and InheritedWidget.

Getting started

Installing package

flutter pub add witt
flutter pub get

Import it

import 'package:witt/witt.dart

Usage

Basic usage

class CounterProvider {
  final counter = ValueNotifier(0);

  void incrementCounter() {
    counter.value++;
  }
}

...
 return WProvider(
  create: (context) => CounterProvider(),
  child: const MaterialApp(
    title: "Example App",
    home: HomePage(),
  ),
);

...

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final counterP = WProvider.of<CounterProvider>(context);
    return Scaffold(
      body: WListener(
        notifier: counterP.counter,
        builder: (context) {
          final counter = counterP.counter.value;
          return Text(counter.toString());
        },
      ),
      floationActionButton: FloationActionButton(
        onPressed: counterP.incrementCounter,
        child: const Icon(Icons.add),
      ),
    );
  }
}

Important note

Widget will not be re-rendered if WListener return const widget.

WListener(
  notifier: counterP.counter,
  (context, value) => const _CounterText(),
);
...

// This widget will not be re-rendered.
class _CounterText extends StatelessWidget {
  const _CounterText({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final counterP = WProvider.of<CounterProvider>(context);
    final counterValue = counterP.counter.value;

    return Center(child: Text(counterValue.toString()));
  }
}

Additional Information

This library is currently on experimental status and not ready for production. The API may change slightly when more features are added, and some use-cases may not be as simple as they could be.

Contributing

Contributions are welcomed!

Here is a curated list of how you can help:

  • Report bugs and scenarios that are difficult to implement
  • Report parts of the documentation that are unclear
  • Update the documentation / add examples
  • Implement new features by making a pull-request

witt's People

Contributors

edsulaiman avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

nghialmt

witt's Issues

Important Update - Suggestion to Use go_router as an Alternative Routing Solution for Witt

[Announcement]

Subject: Important Update - Suggestion to Use go_router as the Routing Solution for Witt

Dear Witt Users,

We have an important update to share regarding the routing capabilities of Witt. In our ongoing efforts to provide you with the best possible development experience, we would like to suggest go_router as the recommended routing solution for your projects.

Why the Suggestion?

After careful consideration, we have found that go_router, a versatile and powerful routing library for Flutter, offers advanced features and benefits that can greatly enhance your application development process. We believe that adopting go_router as the routing solution for Witt can provide you with additional flexibility, functionality, and community support.

Benefits of go_router:

By considering go_router as the recommended routing solution, you gain access to numerous advantages, including:

  • Dynamic Routing: go_router enables dynamic routing, allowing you to easily handle complex navigation flows, deep links, and route transitions.
  • Parameterized Routing: go_router supports parameterized routes, empowering you to pass and handle data within your routes effortlessly.
  • Middleware and Guards: go_router provides middleware and guards functionality, enabling you to execute pre- and post-routing logic, authentication checks, and more.
  • Clean and Simple API: go_router offers a clean and intuitive API, making it easy to define routes, navigate between screens, and handle route transitions.

How to Get Started:

To transition to go_router as the routing solution for your Witt projects, follow these steps:

  1. Refer to the go_router documentation and README to learn how to integrate and use go_router in your Flutter application.
  2. Evaluate the benefits and features go_router provides and consider how it aligns with your routing requirements.
  3. Migrate your existing routing implementation in Witt to utilize go_router based on the go_router documentation and migration guides.
  4. Test and validate the routing functionality in your Witt projects with go_router to ensure a seamless transition.
  5. Leverage the go_router community resources and support channels for any questions or assistance during the migration process.

Please note that we will no longer continue supporting or maintaining Witt's existing routing implementation. As we move forward, we highly encourage you to adopt go_router as the routing solution for your projects based on its benefits and your specific needs.

We understand that migrating to a new routing solution may require effort and adjustments in your codebase. However, we believe that go_router's advanced features and the broader community support will provide you with a more robust and future-proof routing solution.

Thank you for your understanding and cooperation in this transition. We are committed to providing you with the best tools and resources to build exceptional applications with Witt.

Sincerely,

Edwin Sulaiman
Contributor
Witt Team

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.