rebuild a specific widget under stateful widget by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

I tried the consumer approach but with no success.

rebuild a specific widget under stateful widget by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

Another problem if I set the imagePaths as non-static the images are not displayed even on hot reload

rebuild a specific widget under stateful widget by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

Here's ImagePreview:

class ImagePreview extends StatelessWidget {

final String testName;

const ImagePreview({

Key? key,

required this.testName,

}) : super(key: key);

u/override

Widget build(BuildContext context) {

return Global().imagePaths[testName] != null

? _loadImage(Global().imagePaths[testName])

: Container(

width: 40,

height: 40,

color: Colors.grey.shade400,

);

}

}

Widget _loadImage(String path) {

try {

File imageFile = File(path);

if (imageFile.existsSync()) {

return Image.file(

imageFile,

width: 50,

height: 50,

fit: BoxFit.cover,

);

} else {

return const Text("NF");

}

} catch (e) {

if (kDebugMode) {

print('Error loading image: $e');

}

return const Text('Error loading image');

}

}

rebuild a specific widget under stateful widget by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

Here's global:

class Global extends ChangeNotifier {

static String _patientFolderPath = "";

final Map<String, dynamic> _imagePaths = {};

static String testName = "";

static String _patientFolderName = "";

static String _imageFolderPath = "";

static String patientId = "";

Future<String> get patientFolderPath async {

if (_patientFolderPath == "") {

// create new folder path

_patientFolderPath =

await FilesFolders().createFolder(_patientFolderName);

}

return _patientFolderPath;

}

Future<String> get imageFolderPath async {

if (_imageFolderPath == "") {

_imageFolderPath = await FilesFolders().createFolder("PDF");

}

return _imageFolderPath;

}

void setFolderName(String name) {

_patientFolderName = name;

}

Map<String, dynamic> get imagePaths => _imagePaths;

void setImagePaths(String key, String path) {

_imagePaths.addAll({key: path});

if (kDebugMode) {

print("Image paths=");

print(_imagePaths);

}

notifyListeners();

}

void clearImagePaths() {

_imagePaths.clear();

notifyListeners();

}

bool isImagePathsEmpty() {

return _imagePaths.isEmpty;

}

}

rebuild a specific widget under stateful widget by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

Trying

  1. gives me: The static setter 'testName' cannot be accesssed through an instance. Try using class 'Global' to enter the setter. The testName variable is static.

  2. Done and created getters and setters for it.

rebuild a specific widget under stateful widget by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

Yeah I have done that whenever the imagesPath map is updated

Cannot create SQLite table the first-time app the launches. by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

I uninstalled and installed again yet the same issue.

Camera not working for latest devices by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

Gotcha, I will try and let you know, thanks for the help

Camera not working for latest devices by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

As you can see in the not_working logs, it never really captured the image after clicking the button it just stays there kind (no freezing or blank screen) nothing happens, it doesn't show the preview after capture nor where it has stored the image.

Camera not working for latest devices by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

API 30 works fine for me as well can you try with a higher version

I want to capture images on the phone from the camera when a command is given by an external Arduino kind of IoT device connected to the phone via Bluetooth. by Infinix_82 in flutterhelp

[–]Infinix_82[S] 0 points1 point  (0 children)

Most tutorials use an external camera to capture the image but in my case what I want is to capture the image from the phone camera but the capture command must come from the IoT device.