NavigationBar从“package:flutter/src/material/navigation_bar.dart”和“package:flutter_onboarding_slider/navigation_bar.dart”导入

nhaq1z21  于 2023-06-24  发布在  Flutter
关注(0)|答案(2)|浏览(128)
    • 我面临的错误,而运行错误是因为packges或其他东西,我已经删除了所有的旧代码,并添加新的仍然面临以下错误。

错误:“NavigationBar”是从“package:flutter/src/material/navigation_bar. dart”和“package:flutter_onboarding_slider/navigation_bar. dart”导入的。appBar:NavigationBar(^^^^^^^^^^^^^:警告:空感知操作'的操作数?.'具有排除null的类型' GoogleMapController '。lib/.../map/map. dart:62

  • 'GoogleMapController'来自'package:google_maps_flutter/google_maps_flutter. dart'('/D:/flutter/. pub-cache/hosted/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(^

import 'package:flutter/cupertino. dart'; import 'package:flutter/material. dart'; import 'package:flutter_onboarding_slider/flutter_onboarding_slider. dart'; import 'package:fyppedometer/mainScreens/Navigation/navigationBar.dart'; import 'package:fyppedometer/widgets/constants. dart'; import 'package:fypedometer/widgets/text. dart';
class MyHome extends StatefulWidget {const MyHome({Key?key}):super(key:key);

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

}
class_MyHomeState扩展State {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),
                                  ),
                                );
                              })
                            ],
                          ),
                        ),
                      ),
                    )
                  ],
                )
              ]),
        ),
      ],
    ),
  );
}

}

egmofgnx

egmofgnx1#

使用showhide导入库的一部分。

// Import only foo.
import 'package:lib1/lib1.dart' show foo;

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

有关详细信息,请参见使用库。

qyswt5oh

qyswt5oh2#

要解决这个问题,首先导入你的包,使用*变量,如下所示:-

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

然后使用你的class/widget和这个变量。

drawer: nav.NavigationDrawer(),

相关问题