Reputation: 11
In flutterflow, when try to compile a customcode, the following error keeps presisting. [error: Unknown error compiling custom code. A common cause is a custom widget or action whose name in the code does not match the name provided in the editor.]
// Automatic FlutterFlow imports
import '../../backend/backend.dart';
import '../../flutter_flow/flutter_flow_theme.dart';
import '../../flutter_flow/flutter_flow_util.dart';
import '../widgets/index.dart'; // Imports other custom widgets
import '../../flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Fluid Action card display',
debugShowCheckedModeBanner: false,
home: Scaffold(
body: FluidActionCard(
color1: Colors.greenAccent.shade400,
color2: Colors.black12,
backgroundcolor: Colors.grey[900]!,
borderRadius1: BorderRadius.circular(20),
borderRadius2: BorderRadius.circular(20),
TextPosition_Top: 22.0,
TextPosition_Down: 29.0,
height: 400.0,
width: 240.0,
CardCount: 3,
text1: Text(
"Starts From",
style: TextStyle(
color: Colors.white,
fontSize: 18.0,
fontStyle: FontStyle.italic),
),
text2: Text(
"300",
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.w700,
letterSpacing: 2.0,
),
),
Position: 250.0,
shadow: BoxShadow(
color: Colors.black12,
blurRadius: 10.0,
spreadRadius: 0.2,
offset: Offset(0, 3),
),
assetimage: '',
ontap: () {},
),
));
}
FluidActionCard(
{required color1,
required color2,
required backgroundcolor,
required borderRadius1,
required borderRadius2,
required double TextPosition_Top,
required double TextPosition_Down,
required double height,
required double width,
required int CardCount,
required text1,
required text2,
required double Position,
required shadow,
required String assetimage,
required Null Function() ontap}) {}
}
I tried to make varaeties of custom code by importing a packedge from pub.dev , adding dependencies and copy and pasting the code, changing the name in the code to match the widget name I gave etc,,,
when check the exclude from compile box and view in preview mode, it show a message : [place holder fo {widget name, please try compiling]
when try to run the app, running fails due to error occuring in the custom widget and it does it with every packeges.
Also Whenever not cheking the exclude from compile box and try to save the custom widget, it gives a message [No widget found, are you sure you want to save?]
Does sombody know what is the problum? Thx
Upvotes: 1
Views: 3015
Reputation: 298
Make sure you set the name of the custom code in the editor
and in your code, you're creating another instance of a flutter app instead of just creating the widget you want without recreating the App. make sure you keep the name of the widget and the class name the same see image below
Upvotes: 0