I want to reuse my SnackBar widget but I get this error:
The argument type 'ShowSnackBar' can't be assigned to the parameter 'SnackBar'
This is my SnackBarShow code
import 'package:flutter/material.dart';
class ShowSnackBar extends StatelessWidget{
final dynamic state;
const ShowSnackBar({this.state}) ;
@override
Widget build(BuildContext context) {
// TODO: implement build
return SnackBar(content: Text(state.message??'خطا رخ داد.',style: TextStyle(color: Colors.white),
),
elevation: 4,
backgroundColor: Colors.deepPurple,
action: SnackBarAction(label: 'متوجه شدم', onPressed: (){
print("ok");
}),);
}
}
This is some part of my code which use flutter_bloc library and this ShowSnacBar class.I got this error on line 4
BlocListener<AuthenticationBloc,AuthenticationState> (listener: (context,state){
if(state is AuthenticationError){
_scafoldKey.currentState.showSnackBar(
ShowSnackBar(state: state)
);
}
},
Thank you .