Skip to content

Commit 86257ac

Browse files
committed
[1.0.0] Initial stable release.
0 parents  commit 86257ac

File tree

80 files changed

+2413
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2413
-0
lines changed

.gitignore

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Miscellaneous
2+
*.class
3+
*.lock
4+
*.log
5+
*.pyc
6+
*.swp
7+
.DS_Store
8+
.atom/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.fvm/
13+
.melos_tool/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# Visual Studio Code related
22+
.classpath
23+
.project
24+
.settings/
25+
.vscode/
26+
27+
# Flutter/Dart/Pub related
28+
**/doc/api/
29+
.dart_tool/
30+
.flutter-plugins
31+
.flutter-plugins-dependencies
32+
.packages
33+
.pub-cache/
34+
.pub/
35+
build/
36+
flutter_*.png
37+
linked_*.ds
38+
unlinked.ds
39+
unlinked_spec.ds
40+
41+
42+
# Android related
43+
**/android/**/gradle-wrapper.jar
44+
**/android/.gradle
45+
**/android/captures/
46+
**/android/gradlew
47+
**/android/gradlew.bat
48+
**/android/local.properties
49+
**/android/**/GeneratedPluginRegistrant.java
50+
51+
# iOS/XCode related
52+
**/ios/**/*.mode1v3
53+
**/ios/**/*.mode2v3
54+
**/ios/**/*.moved-aside
55+
**/ios/**/*.pbxuser
56+
**/ios/**/*.perspectivev3
57+
**/ios/**/*sync/
58+
**/ios/**/.sconsign.dblite
59+
**/ios/**/.tags*
60+
**/ios/**/.vagrant/
61+
**/ios/**/DerivedData/
62+
**/ios/**/Icon?
63+
**/ios/**/Pods/
64+
**/ios/**/.symlinks/
65+
**/ios/**/profile
66+
**/ios/**/xcuserdata
67+
**/ios/.generated/
68+
**/ios/Flutter/App.framework
69+
**/ios/Flutter/Flutter.framework
70+
**/ios/Flutter/Flutter.podspec
71+
**/ios/Flutter/Generated.xcconfig
72+
**/ios/Flutter/app.flx
73+
**/ios/Flutter/app.zip
74+
**/ios/Flutter/flutter_assets/
75+
**/ios/Flutter/flutter_export_environment.sh
76+
**/ios/ServiceDefinitions.json
77+
**/ios/Runner/GeneratedPluginRegistrant.*
78+
79+
# Exceptions to above rules.
80+
!**/ios/**/default.mode1v3
81+
!**/ios/**/default.mode2v3
82+
!**/ios/**/default.pbxuser
83+
!**/ios/**/default.perspectivev3
84+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
85+
86+
# Web related
87+
lib/generated_plugin_registrant.dart
88+
89+
# Symbolication related
90+
app.*.symbols
91+
92+
# Obfuscation related
93+
app.*.map.json
94+
95+
# Exceptions to above rules.
96+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: b22742018b3edf16c6cadd7b76d9db5e7f9064b5
8+
channel: unknown
9+
10+
project_type: package

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
* Initial stable release.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Mad Brains
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<h1 align="center">AppRunner</h1>
2+
3+
<a href="https://madbrains.ru/"><img src="https://firebasestorage.googleapis.com/v0/b/mad-brains-web.appspot.com/o/logo.png?alt=media" width="200" align="right" style="margin: 20px;"/></a>
4+
5+
[![pub package](https://img.shields.io/pub/v/app_runner.svg)](https://pub.dartlang.org/packages/app_runner)
6+
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7+
8+
Launch your Flutter app like a pro! AppRunner is a configurator for quick and controlled launch of your application, with features that runApp does not have.
9+
10+
## Features
11+
* Get your application up and running quickly.
12+
* Allows you to run code without blocking your application from launching.
13+
* Show your independent splash screen while loading the app. AppRunner does not block the first call of the widget, do you practically won't see the native splash screen.
14+
* Allows you to reload the widget tree if you need it.
15+
* Your code will run in a safe environment for both Dart code and Flutter code. AppRunner catches and handles errors, preventing your application from breaking at runtime.
16+
* Configuring the zone of your application is much easier.
17+
* With AppRunner you can easily override ErrorWidget for debug and release mode.
18+
* Lets you just use your WidgetsBinding implementation.
19+
* And the very last and most important argument to use AppRunner in your application, it is very easy to integrate into your application, and its configuration does not take much time.
20+
21+
<table>
22+
<tr>
23+
<td>Splash Screen</td>
24+
<td>Debug Error Screen</td>
25+
<td>Release Error Screen</td>
26+
</tr>
27+
<tr>
28+
<td><img src="docs/assets/run.gif" width=200 height=400 alt="run" /></td>
29+
<td><img src="docs/assets/debug-error.jpg" width=200 height=400 alt="debug-error" /></td>
30+
<td><img src="docs/assets/release-error.jpg" width=200 height=400 alt="release-error" /></td>
31+
</tr>
32+
</table>
33+
34+
## Installing
35+
Add this to your package's `pubspec.yaml` file:
36+
```yaml
37+
dependencies:
38+
app_runner: 1.0.0
39+
```
40+
41+
## Usage
42+
43+
This is how your application launch looked like before:
44+
```dart
45+
import 'package:flutter/material.dart';
46+
47+
void main() {
48+
runApp(MyApp());
49+
}
50+
```
51+
52+
It is simply by attaching your widget to the root. But in order to catch errors, it was necessary to use runZonedGuarded, then our code will become like this:
53+
```dart
54+
import 'dart:async';
55+
56+
import 'package:flutter/material.dart';
57+
58+
void main() {
59+
runZonedGuarded<void>(
60+
() {
61+
runApp(MyApp());
62+
},
63+
(Object error, StackTrace stackTrace) {...},
64+
zoneValues: ...,
65+
zoneSpecification: ...,
66+
);
67+
}
68+
```
69+
70+
But we also need to initialize some code to launch the application, for example Firebase:
71+
```dart
72+
import 'dart:async';
73+
74+
import 'package:flutter/material.dart';
75+
void main() {
76+
runZonedGuarded<void>(
77+
() async {
78+
WidgetsFlutterBinding.ensureInitialized();
79+
80+
await Firebase.initializeApp();
81+
82+
HydratedBloc.storage = await HydratedStorage.build(
83+
storageDirectory: await getApplicationDocumentsDirectory(),
84+
);
85+
86+
Bloc.observer = MyBlocObserver();
87+
88+
runApp(MyApp());
89+
},
90+
(Object error, StackTrace stackTrace) {},
91+
zoneValues: ...,
92+
zoneSpecification: ...,
93+
);
94+
}
95+
```
96+
97+
And what do we have:
98+
* The launch of the widget is blocked by the third-party code.
99+
* The splash screen is implemented in MyApp, that is, it will be present in the tree when it is no longer needed.
100+
* Not the most beautiful and understandable code.
101+
102+
Let's fix this with AppRunner (all possible parameters are shown here, it is not necessary to use all of them):
103+
```dart
104+
import 'package:app_runner/app_runner.dart';
105+
import 'package:flutter/material.dart';
106+
107+
void main() {
108+
appRunner(
109+
RunnerConfiguration(
110+
widgetConfig: WidgetConfiguration(
111+
app: MyApp(), // Our application
112+
splash: const Splash(), // Our splash screen
113+
errorBuilder: (BuildContext context, FlutterErrorDetails errorDetails) => MyErrorScreen(errorDetails), // Our flutter error screen during debugging
114+
releaseErrorBuilder: (BuildContext context) => MyReleaseErrorScreen(), // Our flutter error screen during release
115+
onFlutterError: (FlutterErrorDetails errorDetails) {
116+
// Flutter error handling
117+
dev.log(errorDetails.toString(),
118+
name: 'onFlutterError', stackTrace: errorDetails.stack);
119+
},
120+
initializeBinding: () => CustomWidgetsFlutterBinding(), // Creating your WidgetsFlutterBinding
121+
),
122+
zoneConfig: ZoneConfiguration(
123+
onZoneError: (Object error, StackTrace stackTrace) {
124+
// Dart error handling
125+
dev.log(error.toString(),
126+
name: 'onZoneError', stackTrace: stackTrace);
127+
},
128+
zoneValues: ..., // Your zone parameters
129+
zoneSpecification: ..., // Your zone specifications
130+
),
131+
preInitializeFunctions: (WidgetsBinding binding) async {
132+
// Custom code initialization.
133+
// You don't need to call WidgetsFlutterBinding.ensureInitialized();
134+
// WidgetsBinding is also available here if you need it.
135+
136+
await Firebase.initializeApp();
137+
138+
HydratedBloc.storage = await HydratedStorage.build(
139+
storageDirectory: await getApplicationDocumentsDirectory(),
140+
);
141+
142+
Bloc.observer = MyBlocObserver();
143+
},
144+
),
145+
);
146+
}
147+
```
148+
149+
If you need to reload the widgets, you can do:
150+
```dart
151+
reloadWidget(context);
152+
153+
// or
154+
155+
context.reloadWidget();
156+
```
157+
158+
## Example
159+
The [Example][example] is in the corresponding folder
160+
161+
[example]: https://github.com/MadBrains/App-Runner-Flutter/tree/main/example/

0 commit comments

Comments
 (0)