You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Facing issues when we try to import custom widgets and library dependency imports.
Importing custom button widget gives error: import 'button.dart';
EvalExample.dart
import 'package:flutter/material.dart';
import 'package:flutter_eval/flutter_eval.dart';
class EvalExample extends StatelessWidget {
const EvalExample({super.key});
@override
Widget build(BuildContext context) {
return const CompilerWidget(
packages: {
'example': {
'main.dart': '''
import 'package:flutter/material.dart';
import 'button.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Button(
label: 'Go Back',
onPressed: () {
Navigator.pop(context);
},
),
),
);
}
}
'''
}
},
/// Specify which library (i.e. which file) to use as an entrypoint.
library: 'package:example/main.dart',
/// Specify which function to call as the entrypoint.
/// To use a constructor, use "ClassName.constructorName" syntax. In
/// this case we are calling a default constructor so the constructor
/// name is blank.
function: 'MyApp.',
/// Specify the arguments to pass to the entrypoint. Generally these
/// should be dart_eval [$Value] objects, but when invoking a static or
/// top-level function or constructor, [int]s, [double]s, and [bool]s
/// should be passed directly.
args: [null],
);
}
}
Button.dart
import 'package:flutter/material.dart';
class Button extends StatelessWidget {
final String label;
final Color color;
final double fontSize;
final TextStyle textStyle;
final Color textColor;
final VoidCallback? onPressed;
const Button({
super.key,
required this.label,
this.textColor = Colors.white,
this.fontSize = 16,
this.textStyle = const TextStyle(fontStyle: FontStyle.normal),
this.color = Colors.blueAccent,
this.onPressed,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: color,
),
onPressed: onPressed,
child: Text(
label,
style: textStyle.copyWith(fontSize: fontSize,color: textColor),
),
);
}
}
Facing issues when we try to import custom widgets and library dependency imports.
Importing custom button widget gives error: import 'button.dart';
EvalExample.dart
Button.dart
Error Log:
The text was updated successfully, but these errors were encountered: