'Error: Required named parameter 'path' must be provided
im getting below errors in my code. how to solve this. appreciate your help on this
Error: Required named parameter 'path' must be provided.
Navigator.push(context, MaterialPageRoute(builder: (builder)=> CameraViewPage()));Context: Found this candidate, but the arguments don't match. const CameraViewPage({Key? key, required this.path}) : super(key: key);
Error: Too many positional arguments: 0 allowed, but 1 found. Try removing the extra positional arguments. await _cameraController.takePicture(path);
CameraSreen.dart
void takePhoto(BuildContext context) async {
final path = join((await getTemporaryDirectory()).path,"${DateTime.now()}.png");
await _cameraController.takePicture(path);
Navigator.push(context, MaterialPageRoute(builder: (builder)=> CameraViewPage()));
}
CameraView.dart
class CameraViewPage extends StatelessWidget {
const CameraViewPage({Key? key, required this.path}) : super(key: key);
final String path;
Solution 1:[1]
Try this you have made path as required argument for CameraViewPage class so you are not passing path while navigating to next screen.
void takePhoto(BuildContext context) async {
final path = join((await getTemporaryDirectory()).path,"${DateTime.now()}.png");
await _cameraController.takePicture(path);
Navigator.push(context, MaterialPageRoute(builder: (builder)=> CameraViewPage(path:path)));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | eshanz7 |
