首页 > 解决方案 > 编译错误:“页面”是从“package:flutter/src/widgets/navigator.dart”和“package:intro_views_flutter/UI/page.dart”导入的

问题描述

我刚刚下载了正在使用的应用程序intro_views_flutter: ^2.8.0。但由于以下编译错误,我无法运行它。

Compiler message:
/C:/Users/Administrator/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/intro_views_flutter-2.8.0/lib/intro_views_flutter.dart:241:11: Error: 'Page' is imported from both 'package:flutter/src/widgets/navigator.dart' and 'package:intro_views_flutter/UI/page.dart'.
          Page(
          ^^^^

环境是sdk: ">=2.1.0 <3.0.0"

以下是已使用的代码块package:intro_views_flutter

import 'package:flutter/material.dart';
import 'package:intro_views_flutter/Models/page_view_model.dart';
import 'package:intro_views_flutter/intro_views_flutter.dart';
import 'package:starterkit/utils/constants.dart';
import 'package:starterkit/utils/styles.dart';
import 'package:starterkit/views/partials/fake_bottom_buttons.dart';

import 'home.dart';

class IntroScreenPage extends StatefulWidget {
  @override
  _IntroScreenPageState createState() => _IntroScreenPageState();
}

class _IntroScreenPageState extends State<IntroScreenPage> {
  static final List<String> images = [
    'assets/images/acelords_brand.png',
    'assets/images/undraw_happy_music_g6wc.png',
    'assets/images/undraw_the_world_is_mine_nb0e.png',
  ];

  static final List<String> titles = [
    Constants.appName,
    'Flutter Boilerplate/Starter Kit',
    'Enjoy Coding',
  ];

  static final List<String> descriptions = [
    'Built by Lexx YungCarter',
    'A Proud product of AceLords System Engineers',
    'Just start coding!',
  ];

  final pages = [
    PageViewModel(
      pageColor: Styles.appPrimaryColor,
      // iconImageAssetPath: 'assets/air-hostess.png',
      bubble: Image.asset(images[1]),
      title: Text(titles[0]),
      body: Text(descriptions[0]),
      titleTextStyle: TextStyle(fontFamily: 'Radicals', color: Colors.white),
      bodyTextStyle: Styles.p.copyWith(
        color: Colors.white,
        fontFamily: 'Comfortaa',
        fontStyle: FontStyle.italic,
      ),
      mainImage: Image.asset(
        images[0],
        height: 285.0,
        width: 285.0,
        alignment: Alignment.center,
      )
    ),
    PageViewModel(
      pageColor: const Color(0xFF8BC34A),
      iconImageAssetPath: images[2],
      title: Text(titles[1]),
      body: Text(descriptions[1]),
      mainImage: Image.asset(
        images[1],
        height: 285.0,
        width: 285.0,
        alignment: Alignment.center,
      ),
      titleTextStyle: TextStyle(fontFamily: 'Radicals', color: Colors.white),
      bodyTextStyle: Styles.p.copyWith(
        color: Colors.white,
        fontFamily: 'Comfortaa',
        fontStyle: FontStyle.italic,
      ),
    ),
    PageViewModel(
      pageColor: const Color.fromRGBO(22, 160, 133, 1),
      iconImageAssetPath: images[1],
      title: Text(titles[2]),
      body: Text(descriptions[2]),
      mainImage: Image.asset(
        images[2],
        height: 285.0,
        width: 285.0,
        alignment: Alignment.center,
      ),
      titleTextStyle: TextStyle(fontFamily: 'Radicals', color: Colors.white),
      bodyTextStyle: Styles.p.copyWith(
        color: Colors.white,
        fontFamily: 'Comfortaa',
        fontStyle: FontStyle.italic,
      ),
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return Builder(
      builder: (context) => Container(
        color: Colors.red,
        child: Scaffold(
//          persistentFooterButtons: FakeBottomButtons(height: 40.0), // showcase admob banner
          body: IntroViewsFlutter(
            pages,
            showNextButton: true,
            showBackButton: true,
            onTapDoneButton: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => HomePage(),
                ),
              );
            },
            pageButtonTextStyles: TextStyle(
              color: Colors.white,
              fontSize: 18.0,
            ),
          ),
        ),
      ),
    );
  }

}

我不确定为什么会发生此错误。请帮我。;(

标签: fluttercompiler-errors

解决方案


推荐阅读