在使用方面我还是一个初学者flutter_bloc。
我尝试flutter_bloc并好奇如何在关闭页面时将块类重置为其初始值。
my_bloc_class.dart
class sumtotal_detail_transactionsbloc extends Bloc<String, String>{
    @override
    String get initialState => '0';
    @override
    Stream<String> mapEventToState(String sumtotal_detail_transactions) async* {
        yield sumtotal_detail_transactions.toString();
    }
}
Run Code Online (Sandbox Code Playgroud)
我的小部件带有BlocBuilder.
BlocBuilder<sumtotal_detail_transactionsbloc, String>(
    builder: (context,sumtotal_detail_transactions) => Text(
        sumtotal_detail_transactions,style: TextStyle(
                fontSize: 12,
                color: Colors.brown[300]
            ),
        )
),
Run Code Online (Sandbox Code Playgroud)
每当我关闭页面或导航到该页面时,如何始终/自动将sumtotal_detail_transactions其重置为初始值?
如果该值始终保持/存储原样,它将破坏我的应用程序。
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           16485 次  |  
        
|   最近记录:  |