Code Monkey home page Code Monkey logo

panic's Introduction

Stand With Ukraine

Panic screenshots

Supported platforms

Current Build Status. Panic is released under the MIT license. Effective Dart PRs welcome!

Content

Features

Panics a Flutter app.

This allows a flutter app to terminate immediately and provide feedback to the caller of the app. Panic should be used when an app reaches an unrecoverable state.

Requirements

  • Dart: 2.14.0+
  • Flutter : 2.5.0+

Install

dependencies:
  panic: ^0.0.1

Example

  1. Add GlobalKey<NavigatorState>() to MaterialApp widget.
// `appKey` should be globally accessible in an app.
final appKey = GlobalKey<NavigatorState>();

class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: appKey,
      home: Home(),
    );
  }
}
  1. Initialized Panic.
import 'package:panic/panic.dart';
// `panic` should be globally accessible in an app
final panic = Panic(appKey);
  1. Panic a flutter app when you really need it.
  static Future<Result<DiscoverResponse?, NetworkError>> fetchDiscover() async {
    final response = await _client.get(
      Uri.parse('$baseUrl/discover/movie?api_key=$themoviedbApiKey&page=1'),
    );

    if (response.statusCode == 200) {
      // Panic app if some important parameters are missed e.g.,
      // some field in a Header or in a Body.
      if (!response.headers.containsKey('MY MISSING KEY')) {
        panic.app();
      }
      return Success(DiscoverResponse.fromJson(response.body));
    } else {
      throw NetworkError(response.statusCode);
    }
  }

To see examples of the following package on a device or simulator:

cd example && flutter run

Support

Post issues and feature requests on the GitHub issue tracker.

License

The source code of Panic project is available under the MIT license. See the LICENSE file for more info.

panic's People

Contributors

minikin avatar

Watchers

 avatar  avatar  avatar

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.