Trying to figure out this flutter problem. The below code has the showSnackbar as deprecated, and am trying to figure out with the fix is. The second code is my attempt to fix the problem. A new problem comes up with "The getter 'ScaffoldMessenger' isn't defined for the type 'ScaffoldState'.". The error tells me to import material.dart file but it is already imported.
Any help is appreciated.
Padding(
padding: const EdgeInsets.all(10.0),
child: GestureDetector(
onTap: ()async{
if(!await authProvider.signIn()){
_key.currentState.showSnackBar(
SnackBar(content: Text("Login failed"))
);
}
},
Padding(
padding: const EdgeInsets.all(10.0),
child: GestureDetector(
onTap: ()async{
if(!await authProvider.signIn()){
_key.currentState.ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Login failed"))
);
}
},
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…