calendar_views
calendar_views copied to clipboard
Sample build fails with - Error: 'Page' is imported from both ...
Cloned repo, opened sample project in Android studio. Tried to run it... fails...
Launching lib/main.dart on iPhone 11 in debug mode...
Removing obsolete reference to flutter_assets from Runner.xcodeproj
Upgrading project.pbxproj
Project base configurations detected, removing.
Compiler message:
lib/days_page_view_example.dart:164:16: Error: 'Page' is imported from both 'package:flutter/src/widgets/navigator.dart' and 'package:calendar_views_example/utils/page.dart'.
return new Page.forDays(
^^^^
lib/month_page_view_example.dart:142:16: Error: 'Page' is imported from both 'package:flutter/src/widgets/navigator.dart' and 'package:calendar_views_example/utils/page.dart'.
return new Page.forMonth(
^^^^
Running Xcode build...
Xcode build done. 20.9s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
Compiler message:
lib/days_page_view_example.dart:164:16: Error: 'Page' is imported from both 'package:flutter/src/widgets/navigator.dart' and 'package:calendar_views_example/utils/page.dart'.
return new Page.forDays(
^^^^
lib/month_page_view_example.dart:142:16: Error: 'Page' is imported from both 'package:flutter/src/widgets/navigator.dart' and 'package:calendar_views_example/utils/page.dart'.
return new Page.forMonth(
^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 11.
Flutter doctor:
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.18.0-13.0.pre, on Mac OS X 10.15.4 19E287, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.6)
[✓] Connected device (2 available)
• No issues found!
This is due to the new Page class from flutter. The plugin owner must change the name of its Page class. I can make a pr in the next days.
Or alternatively, one can specify where to get the definition of "Page" using the as
import prefix. Avoiding naming conflicts with Flutter is discussed here: https://github.com/flutter/flutter/issues/34395
Change:
import 'utils/all.dart';
To:
import 'utils/all.dart' as Utils;
and add Utils.
to specify that the following value is found in the utils/all.dart
path.
Change values such as:
Widget _monthPageBuilder(BuildContext context, DateTime month) {
return new Page.forMonth(
month: month,
);
}
To:
Widget _monthPageBuilder(BuildContext context, DateTime month) {
return new Utils.Page.forMonth(
month: month,
);
}
Resolved with #26