-
Notifications
You must be signed in to change notification settings - Fork 870
Description
Bug description
I copied the exact same code from the example
but I get this error
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Unable to load asset: "packages/timezone/data/latest_all.tzf". The asset does not exist or has empty data. #0 PlatformAssetBundle.load.<anonymous closure> (package:flutter/src/services/asset_bundle.dart:333:13) <asynchronous suspension> #1 _SfCalendarState._loadDataBase (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:4228:31) <asynchronous suspension> #2 _SfCalendarState.initState.<anonymous closure> (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:2880:26) <asynchronous suspension>
so I added this to the main
https://github.com/syncfusion/flutter-widgets/blob/master/packages/syncfusion_flutter_calendar/example/lib/main.dart
Steps to reproduce
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:timezone/data/latest_all.dart' as tz;
import 'package:timezone/timezone.dart' as tz;
import 'app.dart';
import 'core/injection_container.dart';
import 'features/weather/domain/entities/weather_model.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Load environment variables
await dotenv.load(fileName: "api_keys.env");
// Initialize Hive
await Hive.initFlutter();
Hive.registerAdapter(WeatherModelAdapter());
await Hive.openBox('weatherBox');
// Initialize dependencies
await initializeDependencies();
// Initialize timezone data
tz.initializeTimeZones();
tz.setLocalLocation(tz.getLocation('America/Detroit'));
runApp(const MyApp());
}
Code sample
Code sample
pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
country_flags: ^3.2.0
cross_file: ^0.3.4+2
data_widget: ^0.0.2
gap: ^3.0.1
skeletonizer: ^1.4.3
phonecodes: ^0.0.4
syntax_highlight: ^0.4.0
email_validator: ^3.0.0
expressions: ^0.2.5+2
image: ^4.5.4
amplify_flutter: ^2.6.1
amplify_auth_cognito: ^2.6.1
amplify_authenticator: ^2.3.3
amplify_api: ^2.6.1
flutter_riverpod: ^2.6.1
flutter_iconly: ^1.0.2
iconly: ^1.0.1
weather_icons: ^3.0.0
go_router: ^14.8.1
flutter_animate: ^4.5.2
lucide_icons: ^0.257.0
two_dimensional_scrollables: ^0.3.3
universal_image: ^1.0.9
flutter_svg: ^2.0.17
multi_split_view: ^3.6.0
awesome_flutter_extensions: ^1.3.0
flutter_solidart: ^1.7.1
get: ^4.7.2
collection: ^1.19.1
flutter_bloc: ^9.1.0
cached_network_image: ^3.4.1
file_picker: ^9.2.1
geolocator: ^14.0.0
geocoding: ^3.0.0
flutter_dotenv: ^5.2.1
equatable: ^2.0.7
amplify_storage_s3: ^2.6.1
dart_openai: ^5.1.0
get_it: ^8.0.3
intl: ^0.19.0
floor: ^1.5.0
retrofit: ^4.4.2
ionicons: ^0.2.2
url_launcher: ^6.3.1
image_picker: ^1.1.2
dio: ^5.8.0+1
syncfusion_flutter_charts: ^29.1.38
http: ^1.3.0
hive: ^2.2.3
hive_flutter: ^1.1.0
spritewidget: ^2.0.1
connectivity: ^3.0.6
shared_preferences: ^2.5.3
line_icons: ^2.0.3
webview_flutter: ^4.11.0
auto_size_text: ^3.0.0
expandable: ^5.0.1
flutter_spinkit: ^5.2.1
package_info: ^2.0.2
flutter_staggered_grid_view: ^0.7.0
syncfusion_flutter_calendar: ^29.1.39
# timezone: ^0.10.0
# flutter_native_timezone: ^2.0.0
uuid: ^4.5.1
timezone: ^0.10.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
solidart_lint: ^1.1.2
custom_lint: ^0.6.10
build_runner: ^2.4.15
retrofit_generator: ^9.1.9
floor_generator: ^1.5.0
change_app_package_name: ^1.5.0
hive_generator: ^2.0.1
flutter:
uses-material-design: true
generate: true
assets:
#timezone
- assets/packages/timezone/data/latest_all.tzf
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart' as sf;
class ExamplePage extends StatefulWidget {
const ExamplePage({super.key});
@override
State<ExamplePage> createState() => _ExamplePageState();
}
class _ExamplePageState extends State<ExamplePage> {
late MeetingDataSource _events;
@override
void initState() {
super.initState();
_events = MeetingDataSource(_getInitialMeetings());
}
List<Meeting> _getInitialMeetings() {
final now = DateTime.now();
return [
Meeting(
'Initial Meeting',
now.add(const Duration(hours: 1)),
now.add(const Duration(hours: 2)),
Colors.blue,
false,
),
];
}
void _addNewMeeting() {
final now = DateTime.now();
final newMeeting = Meeting(
'New Event',
now.add(const Duration(hours: 3)),
now.add(const Duration(hours: 4)),
Colors.green,
false,
);
setState(() {
_events.appointments!.add(newMeeting);
_events.notifyListeners(sf.CalendarDataSourceAction.add, [newMeeting]);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
child: Column(
children: [
Row(
children: [
const Text('Day View Calendar'),
IconButton.ghost(
onPressed: _addNewMeeting,
icon: const Icon(Icons.add),
),
],
),
Expanded(
child: sf.SfCalendar(
view: sf.CalendarView.day,
dataSource: _events,
todayHighlightColor: Colors.red,
showNavigationArrow: true,
showCurrentTimeIndicator: true,
),
),
],
),
);
}
}
/// Custom meeting class
class Meeting {
Meeting(this.eventName, this.from, this.to, this.background, this.isAllDay);
final String eventName;
final DateTime from;
final DateTime to;
final Color background;
final bool isAllDay;
}
/// DataSource using the custom `Meeting` model
class MeetingDataSource extends sf.CalendarDataSource {
MeetingDataSource(List<Meeting> source) {
appointments = source;
}
Meeting _getMeeting(int index) => appointments![index] as Meeting;
@override
DateTime getStartTime(int index) => _getMeeting(index).from;
@override
DateTime getEndTime(int index) => _getMeeting(index).to;
@override
String getSubject(int index) => _getMeeting(index).eventName;
@override
Color getColor(int index) => _getMeeting(index).background;
@override
bool isAllDay(int index) => _getMeeting(index).isAllDay;
}
[Add your code here]
[Add your code here]
[Add your code here]
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Stack Traces
Stack Traces
Performing hot restart...
Syncing files to device iPhone SE (3rd generation)...
Restarted application in 704ms.
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Unable to load asset: "packages/timezone/data/latest_all.tzf".
The asset does not exist or has empty data.
#0 PlatformAssetBundle.load.<anonymous closure> (package:flutter/src/services/asset_bundle.dart:333:13)
<asynchronous suspension>
#1 _SfCalendarState._loadDataBase (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:4228:31)
<asynchronous suspension>
#2 _SfCalendarState.initState.<anonymous closure> (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:2880:26)
<asynchronous suspension>
On which target platforms have you observed this bug?
iOS
Flutter Doctor output
Doctor output
emilioboves@Emilios-Mac-Studio data % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3 24D60 darwin-arm64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.98.2)
[✓] Connected device (4 available)
! Error: Browsing on the local area network for Emilio’s iphone . Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Emilio’s iphone . Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• No issues found!
emilioboves@Emilios-Mac-Studio data %