NavigationBar is imported from both 'package:flutter/src/material/navigation_bar.dart' and 'package:flutter_onboarding_slider/navigation_bar.dart'

Viewed 290

**i am facing error while running error is this because of packges or something else i have remove all the old code and add new still facing following error.

Error: 'NavigationBar' is imported from both 'package:flutter/src/material/navigation_bar.dart' and 'package:flutter_onboarding_slider/navigation_bar.dart'. appBar: NavigationBar( ^^^^^^^^^^^^^ : Warning: Operand of null-aware operation '?.' has type 'GoogleMapController' which excludes null. lib/…/map/map.dart:62

  • 'GoogleMapController' is from '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'). package: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:fyppedometer/widgets/text.dart';

    class MyHome extends StatefulWidget { const MyHome({Key? key}) : super(key: key);

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

    }

    class _MyHomeState extends 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),
                                      ),
                                    );
                                  })
                                ],
                              ),
                            ),
                          ),
                        )
                      ],
                    )
                  ]),
            ),
          ],
        ),
      );
    }
    

    }

1 Answers

Use show and hide to import part of a library.

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

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

See Using libraries for details.

Related