Last updated:
0 purchases
panic
Panic
Content #
Features
Requirements
Install
Example
Support
License
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
copied to clipboard
Example #
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(),
);
}
}
copied to clipboard
Initialized Panic.
import 'package:panic/panic.dart';
// `panic` should be globally accessible in an app
final panic = Panic(appKey);
copied to clipboard
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);
}
}
copied to clipboard
To see examples of the following package on a device or simulator:
cd example && flutter run
copied to clipboard
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.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.