Closed kimalphaville closed 1 year ago
These are my stories
import 'sample_button.dart';
Widget primary() => const Button('Button', ButtonStyles.primary);
Widget secondary() => const Button('Button', ButtonStyles.secondary);
Widget disabled() => const Button('Button', ButtonStyles.disabled);
enum ButtonStyles { primary, secondary, disabled }
class Button extends StatelessWidget {
final String text;
final ButtonStyles style;
const Button(this.text, this.style, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
child: TextButton(
onPressed: () => {},
style: TextButton.styleFrom(
foregroundColor: getPrimaryColor(),
backgroundColor: getBackgroundColor(),
side: style == ButtonStyles.secondary
? const BorderSide(width: 0, color: Colors.black87)
: null),
child: Text(text)));
}
Color getPrimaryColor() {
switch (style) {
case ButtonStyles.primary:
return Colors.white;
case ButtonStyles.secondary:
return Colors.black87;
case ButtonStyles.disabled:
return Colors.white;
default:
return Colors.white;
}
}
Color getBackgroundColor() {
switch (style) {
case ButtonStyles.primary:
return Colors.green;
case ButtonStyles.secondary:
return Colors.white;
case ButtonStyles.disabled:
return const Color(0xFFE0E0E0);
default:
return Colors.green;
}
}
}
Flutter version 3.10.4 Monarch version 2.1.10
Could you please provide more information so I can troubleshoot? Here are a few things to try:
monarch run -v
which will tell you the location of the log file "Writing application logs to...". The log file may give us more clues as to what is going on.Hi, this is not a test project.
Here is the monarch run
Writing application logs to /var/folders/7c/rng6cj551p3ctf72tchwt_n40000gn/T/monarch_cli_zYooPz/log_monarch_cli.log
Using flutter sdk at /Users/devkim/fvm/versions/3.10.4/bin/flutter
Enabling Flutter for desktop
This is the pubspec.yaml
name: flutter_sample_app
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+39
environment:
sdk: '>=2.18.6 <3.0.0'
dependencies:
flutter:
sdk: flutter
camera:
sqflite:
path_provider:
path:
cupertino_icons: ^1.0.2
icloud_storage: ^2.2.0
gallery_saver: ^2.3.2
uuid: ^3.0.7
moment_dart: ^0.17.4
image_gallery_saver: ^1.7.1
passcode_screen: ^2.0.1
local_auth: ^2.1.6
image_picker: ^0.8.7
image_cropper: ^3.0.1
firebase_crashlytics: ^3.0.17
firebase_core: ^2.8.0
easy_localization: ^3.0.1
universal_io: ^2.2.0
localstorage: ^4.0.1+2
flutter_image_slideshow: ^0.1.5
package_info_plus: ^3.0.3
flutter_barcode_scanner: ^2.0.0
sqflite_common_ffi: ^2.2.3
mockito: ^5.4.0
photo_manager: ^2.6.0
social_share: ^2.3.1
share_plus: ^6.3.2
purchases_flutter: ^4.12.0
google_mobile_ads: ^3.0.0
flutter_flavorizr: ^2.1.6
flutter_dotenv: ^5.0.2
csc_picker: ^0.2.7
custom_date_range_picker: ^1.0.6
syncfusion_flutter_datepicker: ^21.2.9
persistent_bottom_nav_bar: ^5.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
monarch: ^3.0.0
build_runner: ^2.1.11
flutter:
uses-material-design: true
assets:
- assets/images/
@fertrig `
The error seems to be code related. The error mentions ScaffoldMessenger
. Can you post the code of the story and Widget that is causing the error? It should have ScaffoldMessenger
somewhere in the widget tree.
I added ScaffoldMessenger
stories to the monarch_samples repo. They work well, as expected. You can see the working code here:
Hi. It is still not working. This is the error i have
And this is the file based on the error.
file:///Users/devkim/.pub-cache/hosted/pub.dev/monarch-3.0.1/lib/src/preview/monarch_preview.dart:85:16
@fertrig
The error seems to be code related. The error mentions
ScaffoldMessenger
. Can you post the code of the story and Widget that is causing the error? It should haveScaffoldMessenger
somewhere in the widget tree.I added
ScaffoldMessenger
stories to the monarch_samples repo. They work well, as expected. You can see the working code here:
I copy and pasted these stories, but it still didnt work.
Do you think its a cache issue ? How can i clear cache of monarch ?
@fertrig
Here is my story
stories/my_stories.dart
import 'package:flutter/material.dart';
/// Flutter code sample for [ScaffoldMessenger].
class ScaffoldMessengerExampleApp extends StatelessWidget {
const ScaffoldMessengerExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('ScaffoldMessenger Sample')),
body: const Center(
child: ScaffoldMessengerExample(),
),
),
);
}
}
class ScaffoldMessengerExample extends StatelessWidget {
const ScaffoldMessengerExample({super.key});
@override
Widget build(BuildContext context) {
return OutlinedButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('A SnackBar has been shown.'),
),
);
},
child: const Text('Show SnackBar'),
);
}
}
Widget scaffold_messenger_app() => ScaffoldMessengerExampleApp();
Widget scaffold_messenger() => ScaffoldMessengerExample();
But i still get the error
@fertrig
There is something off. You stated you are on Flutter 3.10.4, but your project is running monarch package 3.0.1. If you were on Flutter 3.10.4, then the monarch package should be version 3.5.0 or greater.
Thus, it could be a dependency caching issue. Try this:
flutter clean
flutter pub upgrade
After that last command, your project should be using monarch package version 3.5.3.
Then do:
monarch run -v
If the stories fail to render again, then please post the output of:
flutter doctor
And also post the contents of your pubspec.lock.
Hi. I am using fvm and the issue occurs after i installed latest fvm version.
It was fixed after doing the
fvm flutter pub upgrade
Thank you
@fertrig
I followede the documentation.
monarch init added sample stories.
but i get an error.