import 'package:flutter/material.dart'; // // Base for all BLoCs. // This class was adapted from https://github.com/boeledi/Streams-Block-Reactive-Programming-in-Flutter // abstract class BlocBase { void dispose(); } class BlocProvider extends StatefulWidget { const BlocProvider({ Key? key, required this.child, required this.bloc, }): super(key: key); final T bloc; final Widget child; @override BlocProviderState createState() => BlocProviderState(); static T of(BuildContext context){ BlocProvider? provider = context.findAncestorWidgetOfExactType>(); return provider!.bloc; } } class BlocProviderState extends State>{ @override void dispose(){ widget.bloc.dispose(); super.dispose(); } @override Widget build(BuildContext context){ return widget.child; } }