导航栏从'package:flutter/src/material/navigation_bar.dart'和'package:flutter_onboarding_slider/navigat



**我在运行时遇到了错误,这是因为包或其他东西,我删除了所有旧代码并添加了新的,仍然面临以下错误。

错误:'NavigationBar'是从两个'package:flutter/src/material/navigation_bar. '导入的。Dart '和'package:flutter_onboarding_slider/navigation_bar.dart'。appBar: NavigationBar (^^^^^^^^^^^^^警告:空感知操作'?的操作数。'的类型'GoogleMapController'不包括null。lib/…/地图/map.dart: 62

  • 'GoogleMapController'来自'package:google_maps_flutter/google_maps_flutter. '飞镖' ('/D:/颤振/.pub-cache/托管/pub.dartlang.org/google_maps_flutter-2.1.7/lib/google_maps_flutter.dart’)。包:google_maps_flutter/google_maps_flutter.dart: 1_controller ? .animateCamera (CameraUpdate.newCameraPosition (CameraPosition (^

    进口"包:颤振/cupertino.dart";导入的包:颤振/material.dart ';导入的包:flutter_onboarding_slider/flutter_onboarding_slider.dart ';导入的包:fyppedometer/mainScreens/导航/navigationBar.dart";导入的包:fyppedometer/widget/constants.dart";导入的包:fyppedometer/widget/text.dart的;

    类MyHome扩展StatefulWidget {const MyHome({钥匙吗?Key}): super(Key: Key);

    @override
    State<MyHome> createState() => _MyHomeState();
    

    }

    类_myhomeestate扩展状态{final Color kDarkBlueColor = Colors.cyan;

    // ignore: non_constant_identifier_names
    List<String> numbers_Height = [
    for (var i = 1.1; i <= 10.0; i = i + 0.1) i.toString()
    ];
    // ignore: non_constant_identifier_names
    List<String> numbers_Weight = [for (var i = 1; i <= 1000; i++) i.toString()];
    int _groupValue = -1;
    String _selectedGender = 'male';
    @override
    Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Container(
    // color: Colors.amber,
    child: OnBoardingSlider(
    buttonText: 'Start',
    onFinish: () {
    Navigator.push(
    context,
    CupertinoPageRoute(
    builder: (context) => Navbar(),
    ),
    );
    },
    buttonTextColor: Colors.cyan,
    // skipTextButton: Text(
    //   'Skip',
    //   style: TextStyle(
    //     fontSize: 16,
    //     color: kDarkBlueColor,
    //     fontWeight: FontWeight.w600,
    //   ),
    // ),
    // trailing: Text(
    //   'Login',
    //   style: TextStyle(
    //     fontSize: 16,
    //     color: kDarkBlueColor,
    //     fontWeight: FontWeight.w600,
    //   ),
    // ),
    // trailingFunction: () {
    //   // Navigator.push(
    //   //   context,
    //   //   CupertinoPageRoute(
    //   //     builder: (context) => LoginPage(),
    //   //   ),
    //   // );
    // },
    controllerColor: kDarkBlueColor,
    totalPage: 3,
    headerBackgroundColor: liteblue,
    pageBackgroundColor: liteblue,
    background: [
    Padding(
    padding: const EdgeInsets.only(top: 210, left: 80),
    child: Image.asset(
    'assets/gender.png',
    height: MediaQuery.of(context).size.height * 0.6,
    width: MediaQuery.of(context).size.width * 0.6,
    ),
    ),
    Padding(
    padding: const EdgeInsets.only(top: 160, left: 60),
    child: Image.asset(
    'assets/walking.png',
    height: MediaQuery.of(context).size.height * 0.7,
    width: MediaQuery.of(context).size.width * 0.7,
    ),
    ),
    Padding(
    padding: const EdgeInsets.only(top: 200, left: 60),
    child: Image.asset(
    'assets/human.png',
    height: MediaQuery.of(context).size.height * 0.6,
    width: MediaQuery.of(context).size.width * 0.6,
    ),
    ),
    ],
    speed: 1.8,
    pageBodies: [
    Container(
    // padding: EdgeInsets.symmetric(horizontal: 40),
    child: Column(
    mainAxisAlignment: MainAxisAlignment.start,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
    const Text(
    'What’s Your Gender',
    textAlign: TextAlign.center,
    style: TextStyle(
    color: Colors.white,
    fontSize: 24.0,
    fontWeight: FontWeight.w600,
    ),
    ),
    const SizedBox(
    height: 10,
    ),
    const Text(
    'Calories & Stride length calculation need it ',
    textAlign: TextAlign.center,
    style: TextStyle(
    color: Colors.white60,
    fontSize: 21.0,
    fontWeight: FontWeight.w600,
    ),
    ),
    const SizedBox(
    height: 20,
    ),
    Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
    Container(
    height: size.height * 0.1,
    width: size.width * 0.5,
    decoration: BoxDecoration(
    borderRadius:
    BorderRadius.circular(25), // radius of 10
    color: Color.fromARGB(255, 19, 65, 103),
    ),
    child: Center(
    child: ListTile(
    leading: Radio<String>(
    activeColor: Colors.white,
    value: 'male',
    groupValue: _selectedGender,
    onChanged: (value) {
    setState(() {
    _selectedGender = value!;
    });
    },
    ),
    title: text(
    textData: "Male",
    color: Colors.white,
    fontsize: 20.0,
    fontweight: FontWeight.bold),
    //  Text(_selectedGender == 'male' ? 'Hello gentlement!' : 'Hi lady!')
    ),
    ),
    ),
    SizedBox(height: 20),
    Container(
    height: size.height * 0.1,
    width: size.width * 0.5,
    decoration: BoxDecoration(
    borderRadius:
    BorderRadius.circular(25), // radius of 10
    color: Color.fromARGB(255, 19, 65, 103),
    ),
    child: Center(
    child: ListTile(
    leading: Radio<String>(
    activeColor: Colors.white,
    value: 'female',
    groupValue: _selectedGender,
    onChanged: (value) {
    setState(() {
    _selectedGender = value!;
    });
    },
    ),
    title: text(
    textData: "Female",
    color: Colors.white,
    fontsize: 20.0,
    fontweight: FontWeight.bold),
    //  Text(_selectedGender == 'male' ? 'Hello gentlement!' : 'Hi lady!')
    ),
    ),
    ),
    ],
    )
    ]),
    ),
    Container(
    // padding: EdgeInsets.symmetric(horizontal: 40),
    child: Column(
    mainAxisAlignment: MainAxisAlignment.start,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
    const Text(
    'How Tall are you?',
    textAlign: TextAlign.center,
    style: TextStyle(
    color: Colors.white,
    fontSize: 28.0,
    fontWeight: FontWeight.w600,
    ),
    ),
    const SizedBox(
    height: 10,
    ),
    const Text(
    'To Personalize Your Fitness Goal ',
    textAlign: TextAlign.center,
    style: TextStyle(
    color: Colors.white60,
    fontSize: 20.0,
    fontWeight: FontWeight.w600,
    ),
    ),
    const SizedBox(
    height: 20,
    ),
    Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
    Center(
    child: Container(
    height: size.height * 0.10,
    width: size.width * 0.5,
    decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(15),
    border: Border.all(
    color: Color.fromARGB(255, 145, 174, 225))),
    child: Center(
    child: text(
    textData: "Height",
    fontsize: 30.0,
    fontweight: FontWeight.bold,
    color: Color.fromARGB(255, 147, 148, 152)),
    ),
    ),
    ),
    SizedBox(
    height: 30,
    ),
    Center(
    child: Container(
    height: size.height * 0.13,
    width: size.width * 0.5,
    decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(20),
    border: Border.all(
    color: Color.fromARGB(255, 92, 89, 89)),
    // color: Colors.white,
    ),
    child: ListWheelScrollView.useDelegate(
    itemExtent: 100,
    // controller: fixedExtentScrollController,
    physics: FixedExtentScrollPhysics(),
    onSelectedItemChanged: (i) {
    print(numbers_Height[i]);
    },
    childDelegate: ListWheelChildLoopingListDelegate(
    children: <Widget>[
    ...numbers_Height.map((String number) {
    
    return Center(
    child: Text(
    number,
    style: const TextStyle(
    fontSize: 28.0,
    color: Colors.white,
    fontWeight: FontWeight.bold,
    fontStyle: FontStyle.normal,
    decoration: TextDecoration.none),
    ),
    );
    })
    ],
    ),
    ),
    ),
    )
    ],
    )
    ]),
    ),
    Container(
    // padding: EdgeInsets.symmetric(horizontal: 40),
    child: Column(
    mainAxisAlignment: MainAxisAlignment.start,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
    const Text(
    'How much do you Weight?',
    textAlign: TextAlign.center,
    style: TextStyle(
    color: Colors.white,
    fontSize: 28.0,
    fontWeight: FontWeight.w600,
    ),
    ),
    const SizedBox(
    height: 10,
    ),
    const Text(
    'To Personalize Your Fitness Goal ',
    textAlign: TextAlign.center,
    style: TextStyle(
    color: Colors.white60,
    fontSize: 20.0,
    fontWeight: FontWeight.w600,
    ),
    ),
    const SizedBox(
    height: 20,
    ),
    Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
    Center(
    child: Container(
    height: size.height * 0.10,
    width: size.width * 0.5,
    decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(15),
    border: Border.all(
    color: Color.fromARGB(255, 145, 174, 225))),
    child: Center(
    child: text(
    textData: "Weight",
    fontsize: 30.0,
    fontweight: FontWeight.bold,
    color: Color.fromARGB(255, 147, 148, 152)),
    ),
    ),
    ),
    SizedBox(
    height: 30,
    ),
    Center(
    child: Container(
    height: size.height * 0.13,
    width: size.width * 0.5,
    decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(20),
    border: Border.all(
    color: Color.fromARGB(255, 92, 89, 89)),
    ),
    child: ListWheelScrollView.useDelegate(
    itemExtent: 100,
    physics: FixedExtentScrollPhysics(),
    onSelectedItemChanged: (i) {
    print(numbers_Weight[i]);
    },
    childDelegate: ListWheelChildLoopingListDelegate(
    children: <Widget>[
    ...numbers_Weight.map((String number) {
    return Center(
    child: Text(
    number, //Here is the child value I would like to get
    style: const TextStyle(
    fontSize: 28.0,
    color: Colors.white,
    fontWeight: FontWeight.bold,
    fontStyle: FontStyle.normal,
    decoration: TextDecoration.none),
    ),
    );
    })
    ],
    ),
    ),
    ),
    )
    ],
    )
    ]),
    ),
    ],
    ),
    );
    }
    

    }

使用showhide导入部分库

// Import only foo.
import 'package:lib1/lib1.dart' show foo;
// Import all names EXCEPT foo.
import 'package:lib2/lib2.dart' hide foo;

详情请参见使用库。

要解决这个问题,首先导入带有变量的包: -

import 'package:QualityCheckApp/upgrade/screens/home/navigation_drawer.dart' as nav;

然后使用类/部件

drawer: nav.NavigationDrawer(),

相关内容

  • 没有找到相关文章

最新更新