'ArCoreController not found
please help me out solving this error on this code: I have created a dart class "Arviewpage" but whenever I try to run this program it throws these types of errors. please help me out m totally frustrated, please tomorrow is my project presentation but my codes are not running. I have searched for many solutions and implemented them too. But every time it gives me another error.
import 'dart:typed_data';
import 'package:flutter_auth_ui/armodelselect.dart';
import 'package:ar_flutter_plugin/ar_flutter_plugin.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_to_byte/image_to_byte.dart';
import 'package:vector_math/vector_math_64.dart' as vector;
import 'armodelselect.dart';
import 'screens/armodelselect.dart';
class arviewpage extends StatefulWidget {
objmodel modeldes;
arviewpage(this.modeldes);
@override
_arviewpageState createState() => _arviewpageState(this.modeldes);
}
class _arviewpageState extends State<arviewpage> {
_arviewpageState(this.modeldes);
void initstate(){
super.initState();
}
late List<double> cubesize;
objmodel modeldes;
late ArCoreController arCoreController;
late Uint8List byteImage,byteImage1;
Future<bool> _onWillPop() async {
Navigator.of(context).pop(true);
return true;
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _onWillPop,
child: Scaffold(
appBar: AppBar(
title: const Text('Xperience'),
),
body: ArCoreView(
onArCoreViewCreated: _onArCoreViewCreated,
),
),
);
}
//functions::::::::::::::::::
void _onArCoreViewCreated(ArCoreController controller) {
arCoreController = controller;
if(modeldes.type=='sphere'){
_addsphere();
}
else if(modeldes.type=="sphere2"){
_addmoonearth();
}
else if(modeldes.type=='cube'){
_addCube();
}
}
//convert image to byteimage
Future<Uint8List> _networkImageToByte(String imageaddress,String imageaddress1) async {
byteImage = await _networkImageToByte(imageaddress);
if(imageaddress1!="0"){
byteImage1=await _networkImageToByte(imageaddress1);
}
return byteImage;
}
//convert cube size to double
List<String> convertStringtodoublearr(String size){
var cubesize=size.split(",");
for(int i=0;i<cubesize.length;i++){
this.cubesize[i]=double.parse(cubesize[i]);
}
return cubesize;
}
//sphere ar model implementation
Future _addsphere() async {
await _networkImageToByte(modeldes.img_url,modeldes.explain);
//description ar model:::::::::::::::::::::::::::::::
final material = ArCoreMaterial(
metallic: 1,
color: Colors.blue,
//metallic: 1.0,
textureBytes: byteImage1,
);
final cube = ArCoreCube(
materials: [material],
size: vector.Vector3(0.5,0.2,0.1)
);
final node = ArCoreNode(
shape: cube,
position: vector.Vector3(0,-0.4,0.5),
);
//sphere texture model ::::::::::::::::::::::::::::::::::::
final eamaterial = ArCoreMaterial(
metallic: 1,
color: Colors.blue,
textureBytes: byteImage,
);
final sphere = ArCoreSphere(
materials: [eamaterial],
radius: double.parse(modeldes.size[0]),
);
final eanode = ArCoreNode(
shape: sphere,
position: vector.Vector3(0,0,-1),
children: modeldes.explain=="0"?[]:[node],
);
arCoreController.addArCoreNode(eanode);
}
//cube ar model implementation
Future _addCube() async{
await _networkImageToByte(modeldes.img_url,modeldes.explain);
//description ar model::::::::::::::::::::::::::::::::::::
final material = ArCoreMaterial(
metallic: 1,
color: Colors.blue,
//metallic: 1.0,
textureBytes: byteImage1,
);
final cube = ArCoreCube(
materials: [material],
size: vector.Vector3(0.5,0.2,0.1)
);
final node = ArCoreNode(
shape: cube,
position: vector.Vector3(0,-0.4,0.5),
);
//cube texture model ::::::::::::::::::::::::::::::::::;
final cube_material = ArCoreMaterial(
metallic: 1,
color: Colors.blue,
//metallic: 1.0,
textureBytes: byteImage,
);
final cube_cube = ArCoreCube(
materials: [cube_material],
size: vector.Vector3(double.parse(modeldes.size[0]),double.parse(modeldes.size[1]),double.parse(modeldes.size[2])),
);
final cube_node = ArCoreNode(
shape: cube_cube,
children: modeldes.explain=="0"?[]:[node],
position: vector.Vector3(0,0,-1),
);
arCoreController.addArCoreNode(cube_node);
}
Future _addmoonearth() async {
await _networkImageToByte(modeldes.img_url,modeldes.explain);
//description ar model:::::::::::::::::::::::::::::::
final material = ArCoreMaterial(
metallic: 1,
color: Colors.blue,
//metallic: 1.0,
textureBytes: byteImage1,
);
final moon = ArCoreSphere(
materials: [material],
radius: 0.05,
);
final node = ArCoreNode(
shape: moon,
position: vector.Vector3(0.2,0.3,0.5),
);
//sphere texture model ::::::::::::::::::::::::::::::::::::
final eamaterial = ArCoreMaterial(
metallic: 1,
color: Colors.blue,
textureBytes: byteImage,
);
final sphere = ArCoreSphere(
materials: [eamaterial],
radius: double.parse(modeldes.size[0]),
);
final eanode = ArCoreNode(
shape: sphere,
position: vector.Vector3(0,0,-1),
children: modeldes.explain=="0"?[]:[node],
);
arCoreController.addArCoreNode(eanode);
}
@override
void dispose() {
arCoreController.dispose();
super.dispose();
}
}
Error: Type 'ArCoreController' not found.
late ArCoreController arCoreController;
^^^^^^^^^^^^^^^^
lib/screens/arviewpage.dart:51:30: Error: Type 'ArCoreController' not found.
void _onArCoreViewCreated(ArCoreController controller) {
^^^^^^^^^^^^^^^^
lib/screens/arviewpage.dart:26:7: Error: 'ArCoreController' isn't a type.
late ArCoreController arCoreController;
^^^^^^^^^^^^^^^^
lib/screens/arviewpage.dart:42:16: Error: The method 'ArCoreView' isn't defined for the class '_arviewpageState'.
- '_arviewpageState' is from 'package:flutter_auth_ui/screens/arviewpage.dart' ('lib/screens/arviewpage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ArCoreView'.
body: ArCoreView(
^^^^^^^^^^
lib/screens/arviewpage.dart:51:30: Error: 'ArCoreController' isn't a type.
void _onArCoreViewCreated(ArCoreController controller) {
^^^^^^^^^^^^^^^^
lib/screens/arviewpage.dart:66:42: Error: Too few positional arguments: 2 required, 1 given.
byteImage = await _networkImageToByte(imageaddress);
^
lib/screens/arviewpage.dart:68:43: Error: Too few positional arguments: 2 required, 1 given.
byteImage1=await _networkImageToByte(imageaddress1);
^
lib/screens/arviewpage.dart:89:22: Error: The method 'ArCoreMaterial' isn't defined for the class '_arviewpageState'.
- '_arviewpageState' is from 'package:flutter_auth_ui/screens/arviewpage.dart' ('lib/screens/arviewpage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ArCoreMaterial'.
final material = ArCoreMaterial(
^^^^^^^^^^^^^^
lib/screens/arviewpage.dart:95:18: Error: The method 'ArCoreCube' isn't defined for the class '_arviewpageState'.
- '_arviewpageState' is from 'package:flutter_auth_ui/screens/arviewpage.dart' ('lib/screens/arviewpage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ArCoreCube'.
final cube = ArCoreCube(
^^^^^^^^^^
lib/screens/arviewpage.dart:99:18: Error: The method 'ArCoreNode' isn't defined for the class '_arviewpageState'.
- '_arviewpageState' is from 'package:flutter_auth_ui/screens/arviewpage.dart' ('lib/screens/arviewpage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ArCoreNode'.
final node = ArCoreNode(
^^^^^^^^^^
lib/screens/arviewpage.dart:106:24: Error: The method 'ArCoreMaterial' isn't defined for the class '_arviewpageState'.
- '_arviewpageState' is from 'package:flutter_auth_ui/screens/arviewpage.dart' ('lib/screens/arviewpage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ArCoreMaterial'.
final eamaterial = ArCoreMaterial(
^^^^^^^^^^^^^^
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
