पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv0.2.1-prerelease

riverpod_navigation

riverpod के साथ Flutter नेविगेशन का प्रबंधन करें

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
14
लाइक
27
Pub अंक
120

पैकेज इंस्टॉल करें

flutter pub add riverpod_navigation

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

RiverpodNavigation एक Flutter पैकेज है जो Riverpod स्टेट मैनेजमेंट सिस्टम के साथ बिना किसी दिक्कत के एकीकृत होकर नेविगेशन प्रबंधन को सरल बनाता है। यह रूट और नेविगेशन इवेंट्स को संभालने के लिए एक प्रतिक्रियाशील, टाइप-सुरक्षित दृष्टिकोण प्रदान करता है, जिससे डेवलपर्स ऐप नेविगेशन को घोषित ढंग से और कुशलता से प्रबंधित कर सकते हैं। Riverpod के डिपेंडेंसी इंजेक्शन और स्टेट मैनेजमेंट का उपयोग करके, यह रूटिंग लॉजिक और UI कंपोनेंट्स के बीच स्पष्ट चिंता के विभाजन की अनुमति देता है। यह पैकेज सभी प्रमुख प्लेटफॉर्म के लिए समर्थन करता है, जिसमें Android, iOS, Web, macOS, Windows और Linux शामिल हैं, जिससे यह क्रॉस-प्लेटफॉर्म एप्लिकेशन के लिए आदर्श बन जाता है।

उपयोग

  • घोषणात्मक मार्ग प्रबंधन
  • क्रॉस-प्लेटफ़ॉर्म नेविगेशन
  • प्रतिक्रियाशील नेविगेशन प्रवाह
  • राज्य-चालित रूटिंग
  • Riverpod स्टेट के साथ एकीकरण
  • डायनामिक रूट हैंडलिंग

मुख्य विशेषताएँ

  • Riverpod-संचालित नेविगेशन
  • प्रकार सुरक्षित मार्ग परिभाषाएँ
  • प्रतिक्रियाशील नेविगेशन अपडेट
  • प्लेटफॉर्म-अनुकूल डिज़ाइन
  • रूटिंग तर्क का स्पष्ट अलगाव
  • नेस्टेड नेविगेटर का समर्थन

इनके लिए उपयुक्त

  • Riverpod का उपयोग करने वाले विकासकर्ता
  • क्रॉस-प्लेटफॉर्म फ्लटर एप्स
  • जटिल नेविगेशन परिदृश्य
  • राज्य-संवेदनशील रूटिंग की आवश्यकता वाले ऐप्स
  • रखरखाव योग्य कोड प्राथमिकता देने वाली टीमें
  • गतिशील रूट की आवश्यकता वाले प्रोजेक्ट

विचार योग्य बातें

  • Riverpod के परिचय होना आवश्यक है
  • सरल ऐप्स के लिए बॉयलरप्लेट बढ़ सकता है
  • नए उपयोगकर्ताओं के लिए सीखने का वक्र
  • अन्य विकल्पों की तुलना में सीमित दस्तावेज़
  • गैर-Riverpod प्रोजेक्ट्स के लिए उपयुक्त नहीं
  • बड़े नेविगेटर्स में संभावित प्रदर्शन ओवरहेड

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

Navigation for Riverpod

Managing Flutter navigation with riverpod.

Usage

Bootstrap

Replace your root ProviderScope with a RiverpodNavigation widget with your routing hierarchy and give the provided delegate and parser to your MaterialApp.router factory.

  final routes = RouteDefinition(
      template: UriTemplate.parse('/'),
      builder: (context, entry) => MaterialPage(
        child: HomeLayout(),
      ),
      next: [
        RouteDefinition(
          template: UriTemplate.parse('/articles/:id'),
          builder: (context, entry) => MaterialPage(
            child: ArticleLayout(
              id: entry.parameters['id']!,
            ),
          ),
        ),
      ],
    );
    return RiverpodNavigation( // Replaces your root ProviderScope
      routes: routes,
      builder: (context, delegate, parser) => MaterialApp.router(
        title: 'Flutter Demo',
        routerDelegate: delegate,
        routeInformationParser: parser,
      ),
    );
Navigate
From a provider

A navigationProvider is exposed and can be used to read the current navigation state.

To access the underlying notifier that allows various actions, use the navigationProvider.notifier provider.

final myProvider = Provider<MyState>((ref) {
        final navigation = ref.watch(navigationProvider.notifier);
        return MyState(
            navigateToArticles: () {
                navigation.navigate(Uri.parse('/articles'))
            },
            pop: () {
                navigation.pop();
            }
        );
    },
);
From a BuildContext

The notifier can be accessed with the navigation extension method from the BuildContext.

@override
Widget build(BuildContext context) {
    return TextButton(
        child: Text('Articles'),
        onPressed: () {
            context.navigation.navigate(Uri.parse('/articles'))
        }
    );
}
Pop behaviour

To customize the behaviour of pops when navigating back, a PopBehavior callback can be provided to the RiverpodNavigation instance. The result indicates whether the current pop action should be updated, cancelled or auto (default behavior which simply replace the route with the parent one).

 RiverpodNavigation(
    popBehaviour: (notifier, stack) {
        if (stack.lastRoute?.key == Key('share-article')) {
          return PopResult.update(Uri.parse('/'));
        }
        return PopResult.auto();
      },
    // ...
 )
URI rewriting

The uri can be modified before they are processed by the router with the uriRewriter property. This can be useful for redirecting or normalizing uris.

 RiverpodNavigation(
    uriRewriter: (notifier, uri) {
        if (uri == Uri.parse('/home')) {
            return Uri.parse('/');
        }
        const publicPrefix = 'https://example.com';
        final stringUri = uri.toString();
        if (stringUri.startsWith(publicPrefix)) {
            return Uri.parse(stringUri.substring(publicPrefix.length);
        }
        return uri;
    },
    // ...
);

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 4 आइटम

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।