fix(bootstraper): invalid place to dispatch onCompleted
This commit is contained in:
@@ -7,13 +7,14 @@ export 'package:markettakers/src/bootstrapper.dart'
|
||||
|
||||
final talker = Talker();
|
||||
|
||||
final commonTheme = ThemeData(
|
||||
final ThemeData commonTheme = ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.deepPurple,
|
||||
brightness: Brightness.dark,
|
||||
).copyWith(secondary: Colors.deepPurpleAccent),
|
||||
secondary: Colors.deepPurpleAccent,
|
||||
),
|
||||
);
|
||||
|
||||
void init() async {
|
||||
Future<void> init() async {
|
||||
await RiveNative.init();
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ class BootstrapState with _$BootstrapState {
|
||||
sealed class BootstrapEvent with _$BootstrapEvent {
|
||||
const factory BootstrapEvent.start() = StartEvent;
|
||||
const factory BootstrapEvent.stageCompleted() = StageCompletedEvent;
|
||||
const factory BootstrapEvent.finished() = FinishedEvent;
|
||||
}
|
||||
|
||||
class BootstrapController extends Bloc<BootstrapEvent, BootstrapState> {
|
||||
BootstrapController(super.initialState) {
|
||||
final Completer<void> completer;
|
||||
BootstrapController(super.initialState, this.completer) {
|
||||
assert(state.stages.isNotEmpty, "Stages list cannot be empty");
|
||||
|
||||
on<StartEvent>((event, emit) {
|
||||
@@ -79,7 +79,7 @@ class BootstrapController extends Bloc<BootstrapEvent, BootstrapState> {
|
||||
|
||||
if (newState.isCompleted) {
|
||||
talker.info("BootstrapController: All stages completed");
|
||||
add(const BootstrapEvent.finished());
|
||||
completer.complete();
|
||||
} else if (await newState.currentStage.isCompleted) {
|
||||
talker.info(
|
||||
"BootstrapController: Stage ${newState.currentStage.title} already completed, skipping",
|
||||
@@ -159,7 +159,10 @@ class Bootstrapper extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) {
|
||||
final controller = BootstrapController(BootstrapState(stages));
|
||||
final controller = BootstrapController(
|
||||
BootstrapState(stages),
|
||||
onCompleted,
|
||||
);
|
||||
controller.add(const BootstrapEvent.start());
|
||||
return controller;
|
||||
},
|
||||
@@ -175,9 +178,10 @@ class Bootstrapper extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 3,
|
||||
flex: 2,
|
||||
child: Center(child: Loader.playing(flavour: LoaderFlavour.big)),
|
||||
),
|
||||
Flexible(flex: 1, child: Container()),
|
||||
Flexible(flex: 1, child: BootstrapFooter()),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -38,8 +38,10 @@ class Loader extends HookWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
final animFile = useMemoized(
|
||||
() => FileLoader.fromAsset(flavour.filepath, riveFactory: Factory.rive),
|
||||
() =>
|
||||
FileLoader.fromAsset("packages/markettakers/${flavour.filepath}", riveFactory: Factory.flutter),
|
||||
);
|
||||
|
||||
return RiveWidgetBuilder(
|
||||
|
||||
Reference in New Issue
Block a user