bridge_me 1.0.4+2 copy "bridge_me: ^1.0.4+2" to clipboard
bridge_me: ^1.0.4+2 copied to clipboard

Bridge frees you from context restrictions. Use the bridge Package

Bridge #

The Bridge widget serves as a centralized configuration point for MaterialApp properties in a Flutter application.

Usage #

To configure MaterialApp using the Bridge widget, follow these steps:

  1. Import the package: Import the package in your Dart file where you want to use it.
import 'package:bridge/main.dart';
  1. Define your MaterialApp: Wrap your MaterialApp widget with the Bridge widget and configure it with desired properties.
import 'package:bridge_me/main.dart';
import 'package:flutter/material.dart';

void main(List<String> args) {
  runApp(startApp());
}

Bridge startApp() {
  return Bridge(
    didChangeAppLifecycleState: (AppLifecycleState state) {
      // Here Write DidChangeAppLifecycleState Code
      print(state);
    },
    initState: (context) {
      // Here Write InitState Code
    },
    home: Scaffold(
      appBar: AppBar(),
      body: Column(
        children: [
          ElevatedButton(
            onPressed: () {
              BridgeNavigate.push(ScreenName());
            },
            child: Text("Next Screen"),
          ),
          ElevatedButton(
            onPressed: () {
              BridgeSnackbar.show(SnackBar(content: Text("Ok")));
            },
            child: Text("Show SnackBar"),
          ),
          ElevatedButton(
            onPressed: () {
              BridgeDialog.show(AlertDialog());
            },
            child: Text("Show AlertDilog"),
          ),
          ElevatedButton(
            onPressed: () {
              // No Nedd Context To Use Provider
              BridgeProvider.of<DemoProvider>().print();
            },
            child: Text("Call Provider"),
          ),
        ],
      ),
    ),
  );
}

In this example, MyApp is wrapped with the Bridge widget, providing centralized configuration for the MaterialApp.


Any Time You Need ❌ Context Just Use ✅useContext to anywhere its global. #

// useContext 

Navigator.of(useContext).push(...);


BridgeSnackbar #

The BridgeSnackbar class provides a simple way to display SnackBars using the Bridge pattern for navigation context.

Usage #

To display a SnackBar using the BridgeSnackbar class, follow these steps:

  1. Import the package: Import the package in your Dart file where you want to use it.
import 'package:bridge/main.dart';
  1. Show the SnackBar: Use the BridgeSnackbar.show method to display the SnackBar.
SnackBar snackBar = SnackBar(content: Text('Hello from Snackbar!'));
BridgeSnackbar.show(snackBar);

This code will display the SnackBar with the specified content.


BridgeNavigate #

The BridgeNavigate class offers utilities for navigating within a Flutter application using the Bridge pattern for navigation context.

Usage #

To navigate within your app using the BridgeNavigate class, follow these steps:

  1. Import the package: Import the package in your Dart file where you want to use it.
import 'package:bridge/main.dart';
  1. Use the navigation methods: Utilize methods like push, pop, canPop, pushNamed, pushReplacementNamed, popAndPushNamed, and pushNamedAndRemoveUntil for navigation tasks.
BridgeNavigate.push(NewScreen());

This code pushes a new screen onto the navigation stack or you no need context.


BridgeDialog #

The BridgeDialog class provides a straightforward way to display AlertDialogs using the Bridge pattern for navigation context.

Usage #

To display an AlertDialog using the BridgeDialog class, follow these steps:

  1. Import the package: Import the package in your Dart file where you want to use it.
import 'package:bridge/main.dart';
  1. Show the AlertDialog: Use the BridgeDialog.show method to display the AlertDialog.
BridgeDialog.show(
  AlertDialog(
    title: Text('Alert'),
    content: Text('This is an alert dialog.'),
    actions: <Widget>[
      TextButton(
        onPressed: () {
          BridgeDialog.pop(); // Close the dialog
        },
        child: Text('OK'),
      ),
    ],
  ),
);

This code will display an AlertDialog with the specified content.


BridgeProvider #

The BridgeProvider class offers a convenient way to access providers using the Bridge pattern for context.

Usage #

To access providers using the BridgeProvider class, follow these steps:

  1. Import the package: Import the package in your Dart file where you want to use it.
import 'package:bridge/main.dart';
  1. Access the Provider: Use the BridgeProvider.of<T> method to access the provider of type T.
MyProvider myProvider = BridgeProvider.of<MyProvider>();

This code retrieves the provider of type MyProvider using the Bridge pattern for context.


These improvements should make the documentation clearer and easier to follow. Let me know if you need further assistance!

1
likes
150
pub points
11%
popularity

Publisher

verified publishercodexsourav.blogspot.com

Bridge frees you from context restrictions. Use the bridge Package

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

cupertino_icons, flutter, provider

More

Packages that depend on bridge_me