arcore_flutter_plugin
arcore_flutter_plugin copied to clipboard
Redeclaration: ArCoreView
I am using ar_fluuter_plugin in my project. and I migrated the app to nullable using migrate tool.
after migration, while debugging the app, I am getting following error.
C:\Users\username\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\arcore_flutter_plugin-0.0.11\android\src\main\kotlin\com\difrancescogianmarco\arcore_flutter_plugin\ArCoreView.kt: (33, 7): Redeclaration: ArCoreView e: C:\Users\username\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\arcore_flutter_plugin-0.1.0-null-safety.3\android\src\main\kotlin\com\difrancescogianmarco\arcore_flutter_plugin\ArCoreView.kt: (44, 7): Redeclaration: ArCoreView
My code is like this:
import 'package:flutter/material.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:arcore_flutter_plugin/arcore_flutter_plugin.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ARCore Flutter Plugin Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'ARCore Flutter Plugin Example'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, /*required*/ required this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late ArCoreController arCoreController;
void _onArCoreViewCreated(ArCoreController controller) {
arCoreController = controller;
arCoreController.onNodeTap = (name) => onTapHandler(name);
arCoreController.onPlaneTap = _onPlaneTapHandler;
}
void onTapHandler(String name) {
showDialog<void>(
context: context,
builder: (BuildContext context) =>
AlertDialog(content: Text('onNodeTap on $name')),
);
}
void _onPlaneTapHandler(List<ArCoreHitTestResult> hits) {
var /*!*/ vector;
var /*!*/ plane;
final moonMaterial = ArCoreMaterial(color: Colors.grey);
final moonShape = ArCoreSphere(
materials: [moonMaterial],
radius: 0.03,
);
final moon = ArCoreNode(
shape: moonShape,
position: vector.Vector3(0.2, 0, 0),
rotation: vector.Vector4(0, 0, 0, 0),
);
final earthMaterial =
ArCoreMaterial(color: Color.fromARGB(120, 66, 134, 244));
final earthShape = ArCoreSphere(
materials: [earthMaterial],
radius: 0.1,
);
final earth = ArCoreNode(
shape: earthShape,
children: [moon],
position: plane.pose.translation + vector.Vector3(0.0, 1.0, 0.0),
rotation: plane.pose.rotation);
arCoreController.addArCoreNodeWithAnchor(earth);
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: ArCoreView(
onArCoreViewCreated: _onArCoreViewCreated,
enableTapRecognizer: true,
),
);
}
}
Please let me know, How can I fix it. Thanks in advance.
use this Prerelease: 0.1.0-null-safety.3 or remove null safety
@ChinmayaGit , thanks for the suggestion. it is working now.