I have a simple class like;
import 'dart:io';
class IDCardClass {
File frontImageFile;
File backImageFile;
}
From front_test.dart class I need to assign a data to frontImageFile and back_test.dart class I need to assign a data to backImageFile.
In my home.dart or another ***.dart class I need to get frontImageFile and backImageFile to show it to user.
My question is How can I access global data from another class in Flutter?
Make the variables to static like this:
class IDCardClass {
static File frontImageFile;
static File backImageFile;
}
Just import the class into the other class and access the variables.
import 'package:your_projectname/your_folder/IDCardClass.dart';
.....
var imageFile = IDCardClass.frontImageFile;
.....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With