You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have setup the store.observer to monitor loading state change and showing an overlay with circular progress indicator when isLoading=true and remove the overlay when isLoading=false. In side a store method, I have code call setLoading(true), update(),setLoading(false). Neither update() nor setLoading(false) triggered store.observer's onLading method. The behaviour results the overlay is always displaying and can not be removed.
Environment
To Reproduce
import 'package:flutter/material.dart';
import 'package:flutter_triple/flutter_triple.dart';
Describe the bug
I have setup the store.observer to monitor loading state change and showing an overlay with circular progress indicator when isLoading=true and remove the overlay when isLoading=false. In side a store method, I have code call setLoading(true), update(),setLoading(false). Neither update() nor setLoading(false) triggered store.observer's onLading method. The behaviour results the overlay is always displaying and can not be removed.
Environment
To Reproduce
import 'package:flutter/material.dart';
import 'package:flutter_triple/flutter_triple.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@OverRide
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
final counter = CounterStore();
late Disposer disposer;
@OverRide
void initState() {
super.initState();
}
@OverRide
void dispose() {
super.dispose();
disposer();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: [
IconButton(
onPressed: counter.undo,
icon: Icon(Icons.arrow_back_ios),
),
IconButton(
onPressed: counter.redo,
icon: Icon(Icons.arrow_forward_ios),
),
],
),
body: Center(
child: ScopedConsumer<CounterStore, int>(
store: counter,
onLoadingListener: (context, isLoading) {},
onErrorListener: (context, error) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(error.toString()),
),
);
},
onLoadingBuilder: (context) => Text('Carregando...'),
onStateBuilder: (context, state) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('You have pushed the button 399 this many times:'),
Text(
'$state',
style: Theme.of(context).textTheme.headlineMedium,
),
],
);
},
),
),
floatingActionButton: TripleBuilder<CounterStore, int>(
store: counter,
builder: (context, triple) {
return FloatingActionButton(
onPressed: triple.isLoading ? null : counter.increment,
tooltip: triple.isLoading ? 'no-active' : 'Increment',
backgroundColor: triple.isLoading ? Colors.grey : Theme.of(context).primaryColor,
child: Icon(Icons.add),
);
},
),
);
}
}
class CounterStore extends Store with MementoMixin {
CounterStore() : super(0);
Future increment() async {
setLoading(true);
await Future.delayed(Duration(milliseconds: 1000));
update(state + 1);
setLoading(false);
}
}
Expected behavior
expect to see the console:
true
1
false
true
2
false
Screenshots
but i see the console:
true
1
true
2
The text was updated successfully, but these errors were encountered: