Problem: Flutter refresh my screen while some value change in my model or in my data.How to achieve that. Solution: In your widget add the below code. Widget build ( BuildContext context ) { return ChangeNotifierProvider ( create : ( _ ) => model , child : Scaffold ( body : Consumer < ViewModel >( builder : ( context , viewModel , child ) { In your viewmodel after change the data call this notifyListeners ();
Problem: I want to create one class file that would be useful for text style for my entire app.How to achieve that? Solution: First you have to create a class file that will be as like below. I had used the roboto font to my app.If you pass the color variable with data then it will show with that color. Otherwise it will show default white color. In largeBold i had used font to be roboto bold. class AppFonts { static TextStyle large ({ Color ? color }) { return TextStyle ( fontSize : Constants . largeFont , fontFamily : 'Roboto' , color : color ?? Colors . white , ); } static TextStyle largeBold ({ Color ? color }) { return TextStyle ( fontSize : Constants . largeFont , fontFamily : 'Roboto' , fontWeight : FontWeight . bold , color : color ?? Colors . white , ); } }