back_button_interceptor_plus 8.1.1 copy "back_button_interceptor_plus: ^8.1.1" to clipboard
back_button_interceptor_plus: ^8.1.1 copied to clipboard

Flutter 升级 3.35.7 之后,对 back_button_interceptor 插件的升级(After Flutter upgrade 3.35.7, the upgrade of back_button_interceptor plugins.)。

example/lib/main.dart

// Developed by Marcelo Glasberg (2019) https://glasberg.dev and https://github.com/marcglasberg
// For more info, see: https://pub.flutter-io.cn/packages/back_button_interceptor_plus
import 'package:back_button_interceptor_plus/back_button_interceptor_plus.dart';
import 'package:flutter/material.dart';

// When pressing the back-button, a message will be printed to the console,
// and no back action will happen.

void main() => runApp(MaterialApp(home: Demo()));

class Demo extends StatefulWidget {
  @override
  DemoState createState() => DemoState();
}

class DemoState extends State<Demo> {
  //
  @override
  void initState() {
    super.initState();
    BackButtonInterceptor.add(myInterceptor);
  }

  @override
  void dispose() {
    BackButtonInterceptor.remove(myInterceptor);
    super.dispose();
  }

  bool myInterceptor(bool stopDefaultButtonEvent, RouteInfo info) {
    print("BACK BUTTON!"); // Do some stuff.
    return true;
  }

  @override
  Widget build(BuildContext context) {
    //
    return Scaffold(
      appBar: AppBar(title: const Text('Back Button Interceptor Example')),
      body: Container(
        color: Colors.green,
        child: const Center(
          child: Text('Click the Back Button\n'
              'and see the message in the console.'),
        ),
      ),
    );
  }
}
0
likes
140
points
122
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter 升级 3.35.7 之后,对 back_button_interceptor 插件的升级(After Flutter upgrade 3.35.7, the upgrade of back_button_interceptor plugins.)。

Repository (GitHub)
View/report issues

Topics

#button #android #navigation

License

BSD-2-Clause (license)

Dependencies

collection, flutter

More

Packages that depend on back_button_interceptor_plus