Code Monkey home page Code Monkey logo

Comments (9)

boyan01 avatar boyan01 commented on August 27, 2024 1

https://stackoverflow.com/questions/49356664/how-to-override-the-back-button-in-flutter

from overlay_support.

boyan01 avatar boyan01 commented on August 27, 2024 1

the cost to implement back pressed for notification is too expensive, it need override Navigator widget. so after consideration, I decided not to implement this feature.

from overlay_support.

pishguy avatar pishguy commented on August 27, 2024

@boyan01

are you sure we can implementing that with your introduced link?

https://stackoverflow.com/questions/57016822/flutter-override-back-button-for-multiple-willpops/57016943

overlay_support is not dialog

from overlay_support.

pishguy avatar pishguy commented on August 27, 2024
showOverlay((context, t) {
  // ignore: missing_return
  return Container(
    color: Color.lerp(Colors.transparent, Colors.black54, t),
    child: FractionalTranslation(
      translation: Offset.lerp(const Offset(0, -1), const Offset(0, 0), t),
      child: Column(
        children: <Widget>[
          DirectMessageNotification(
            message: "xxxxxxxxxxx",
            onReplay: () {
              OverlaySupportEntry.of(context).dismiss();
            },
            key: ModalKey(const Object()),
          ),
        ],
      ),
    ),
  );
}, duration: Duration.zero);



class DirectMessageNotification extends StatelessWidget {
  final VoidCallback onReplay;
  final String message;
  final bool enableBottomLayer;
  final bool enableHeaderLayer;

  const DirectMessageNotification({Key key, this.onReplay, @required this.message, this.enableBottomLayer, this.enableHeaderLayer}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    double notificationHeight = MediaQuery.of(context).size.height * 0.500;
    return SafeArea(
      child: WillPopScope(
        // ignore: missing_return
        onWillPop: () {
          if (onReplay != null) onReplay();
        },
        child: ,
      ),
    );
  }
}

from overlay_support.

boyan01 avatar boyan01 commented on August 27, 2024

onWillPop function need a return value to determine whether intercept back event.

from overlay_support.

pishguy avatar pishguy commented on August 27, 2024

@boyan01 i'm not sure to understand me, could you help me by code to know how can i do that? thanks

from overlay_support.

boyan01 avatar boyan01 commented on August 27, 2024

sorry for late, it seems that OverlaySupport do not support this feature yet. because showOverlay is popup a OverlayEntry on screen, and this OverlayEntry do not belong to any Route, so WillPopScope is useless.

from overlay_support.

boyan01 avatar boyan01 commented on August 27, 2024

also, I have no ideas how to intercept BackEvent on a Widget that not belong to any Route.

so if you want implement dismiss notification when back pressed, a Route is necessary.

from overlay_support.

pishguy avatar pishguy commented on August 27, 2024

i think this library can help you to implementing that:

https://github.com/hey24sheep/backdrop_modal_route

from overlay_support.

Related Issues (20)

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.