zenled / calendar_views

Collection of customisable calendar related widgets for Flutter.
https://pub.dartlang.org/packages/calendar_views
MIT License
102 stars 49 forks source link

Sample build fails with - Error: 'Page' is imported from both ... #24

Open ajaygautam opened 4 years ago

ajaygautam commented 4 years ago

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!
The-Redhat commented 4 years ago

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.

stephensamonte commented 4 years ago

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,
    );
  }
stephensamonte commented 4 years ago

Resolved with #26