Reputation: 427
global variables in flutter app don't work in release mode?My flutter app is working perfectly in debug mode but it's not working release mode.Do I have to wrap global variables inside of class.
My Global variables
void main() => runApp(MyApp(
));
int _character=1 ;
bool language=true;
String str = '';
double _strokeSize=0;
double w;
double h;
double f=28;
// double offset=kToolbarHeight;
Color pickerColor = Color(0xff443a49);
Color currentColor = Color(0xff443a49);
Color strokepickerColor = Color(0xff443a49);
Color strokechangeColor = Color(0xff443a49);
ScreenshotController screenshotController = ScreenshotController();
//rest of the code
}
PS: I'm new to flutter
Upvotes: 0
Views: 109
Reputation: 593
The format is,
class GlobalVariable {
static const int character = 1;
static const bool status = true;
}
And you should use static keyword, then only it will retain value.
Upvotes: 3