dialog_context 0.1.0 copy "dialog_context: ^0.1.0" to clipboard
dialog_context: ^0.1.0 copied to clipboard

discontinuedreplaced by: one_context
outdated

Show Dialog, BottomSheet, ModalBottomSheet and SnackBar without BuildContext.

dialog_context #

Show Dialog, BottomSheet, ModalBottomSheet and SnackBar without BuildContext. #

// example snackBar
DialogContext().showSnackBar(
    snackBar: SnackBar(content: Text('My awesome snackBar!'))
);
// example dialog
DialogContext().showDialog(
    builder: (context) => AlertDialog( 
        title: new Text("The Title"),
        content: new Text("The Body"),
    )
);
// example bottomSheet
DialogContext().showBottomSheet(
    builder: (context) => Container(
    alignment: Alignment.topCenter,
    height: 200,
    child: IconButton(
        icon: Icon(Icons.arrow_drop_down),
        iconSize: 50,
        color: Colors.white,
        onPressed: () => Navigator.pop(context)),
    ),
);

Important: Use the builder of MaterialApp #

MaterialApp(
  builder: (context, widget) => Navigator( // important: Use builder to initiate routes
    onGenerateRoute: (settings) => MaterialPageRoute(
      builder: (context) => DialogContextWidget( // important: Use the DialogContextWidget as root widget
        child: widget,
      ),
    ),
  ),
  home: MyHomePage(title: 'Dialogs without BuildContext'),
);
5
likes
0
pub points
38%
popularity

Publisher

unverified uploader

Show Dialog, BottomSheet, ModalBottomSheet and SnackBar without BuildContext.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on dialog_context