-1

I am using Getx package in flutter and using Firestore to store my data. here is my main.dart

 GetPage(
        name: '/ApartmentDetailedPage/:propertyName/:reraId',
        page: () => ApartmentAdviserDetailedPage(),
        transition: Transition.cupertino,
        transitionDuration: const Duration(seconds: 1)),

while i was giving the parameters as above and in the next page accessing the data then on clicking the property i was getting null operator used on a null value, below is the code of my other file.

    final properties = snapshot.data!.docs
        .map((doc) {
          final data = doc.data() as Map<String, dynamic>;
          final propertyType = data['Property Type'] ?? '';
          final propertyName = data['Property Title'] ?? '';
          final reraId = data['Rera Id'] ?? '';
          if (propertyType == 'Apartment') {
            return GestureDetector(
              onTap: () {
                Get.toNamed('/ApartmentDetailedPage/$propertyName/$reraId',
                    arguments: {
                      'propertyName': data['Property Title'] ?? '',
                      'propertyAddress': data['Property Address'] ?? '',
                      'propertyType': data['Property Type'] ?? '',

I think before i was getting the data into my propertyName and reraId i am using it.But while i was making the changes as follows, my main.dart

GetPage(
        name: '/ApartmentDetailedPage',
        page: () => ApartmentAdviserDetailedPage(),
        transition: Transition.cupertino,
        transitionDuration: const Duration(seconds: 1)),

and the other page as

  final properties = snapshot.data!.docs
        .map((doc) {
          final data = doc.data() as Map<String, dynamic>;
          final propertyType = data['Property Type'] ?? '';
          final propertyName = data['Property Title'] ?? '';
          final reraId = data['Rera Id'] ?? '';
          if (propertyType == 'Apartment') {
            return GestureDetector(
              onTap: () {
                Get.toNamed('/ApartmentDetailedPage',
                    arguments: {
                      'propertyName': data['Property Title'] ?? '',
                      'propertyAddress': data['Property Address'] ?? '',

then there is no issue arising, and the url is domain.Name/ApartmentDetailedPage

  • Experts agree to look elsewhere besides GetX. If you're on the flutter discord, type ?getx. Otherwise, this seven minute video presents a good detailed description of "why not getx": https://youtu.be/zlIgy4es5Ts – Randal Schwartz Jun 21 '23 at 07:00

1 Answers1

1

Instead of loading propertyName just give the id, because in get routes your property name which you are fetching should not contain space in between string - for example your url can't be like YouDomainName/Property Name/reraId it should be like YourDomainName/PropertyName/reraId, no space should be included so just use reraId.