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