Monday, August 15, 2022
HomeiOS Developmentandroid - sort 'Null' isn't a subtype of sort 'UserMatch'

android – sort ‘Null’ isn’t a subtype of sort ‘UserMatch’

[ad_1]

I’m attempting to navigate chat display through UserMatch display. I obtained the error on chat display is “sort ‘Null’ isn’t a subtype of sort ‘UserMatch'”. I’m a newbie in flutter. I actually do not know learn how to deal with with it.
That is the code of my UserMatch display. I suppose the error that’s coming ought to be on this display.

import 'package deal:buis_talk/fashions/user_match_model.dart';
import 'package deal:buis_talk/screens/chat/chat_screen.dart';
import 'package deal:flutter/materials.dart';

import '../../widgets/widgets.dart';

class MatchesScreen extends StatelessWidget {
  static const String routeName="/matches";

  get userMatch => null;

  static Route route(){
    return MaterialPageRoute(
      settings: RouteSettings(identify: routeName),
      builder: (context) => MatchesScreen(),
    );
  }

  @override
  Widget construct(BuildContext context) {
    remaining inactiveMatches = UserMatch.matches
      .the place((match) => match.userId == 1 && match.chat!.isEmpty)
      .toList();
    remaining activeMatches = UserMatch.matches
      .the place((match) => match.userId == 1 && match.chat!.isNotEmpty)
      .toList();

    return Scaffold(
      appBar: const CustomAppBar(title: 'Matches'),
      physique: SingleChildScrollView(
        youngster: Padding(
          padding: const EdgeInsets.all(20.0),
          youngster: Column(
            crossAxisAlignment: CrossAxisAlignment.begin,
            kids: [
              Text('Your Likes', style: Theme.of(context).textTheme.headline5),
              SizedBox(
                height: 100,
                child: ListView.builder(
                  scrollDirection: Axis.horizontal,
                  shrinkWrap: true,
                  itemCount: inactiveMatches.length,
                  itemBuilder: (context, index) {
                    return Column(
                      children: [
                        UserImageSmall(
                          height: 64,
                          width: 64,
                          url: inactiveMatches[index].matchedUser.imageUrls
                        ),
                        Container( width: 16,),
                        Textual content(
                          inactiveMatches[index].matchedUser.identify,
                          model: Theme.of(context).textTheme.bodyText1,
                        ),
                      ],
                    );
                  }
                ),
              ),
              const SizedBox(top: 10),
              const Divider(
                thickness: 3,
                indent: 3,
                endIndent: 3,
                colour: Coloration.fromARGB(255, 190, 19, 19),
                top: 20,
              ),
              const SizedBox(top: 10),
              Textual content('Your Chats',
              model: Theme.of(context).textTheme.headline5),
              ListView.builder(
                shrinkWrap: true,
                // itemCount: activeMatches.size,
                itemCount: activeMatches.size,
                itemBuilder: (context, index) {
                  return InkWell (
                    onTap: () {
                      Navigator.push(
                        context, MaterialPageRoute(
                          // arguments: activeMatches[index],
                          builder: (context) => ChatScreen(userMatch: userMatch,),
                          
                        ),
                      );
                      // Navigator.pushNamed(context,'/chat',
                      //   arguments: activeMatches[index]);
                    },
                    youngster: Row(kids: [
                      UserImageSmall(
                        height: 65,
                        width: 65,
                        url: activeMatches[index].matchedUser.imageUrls,
                        ),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.begin,
                          kids: [
                            Text(
                              activeMatches[index].matchedUser.identify,
                              model: Theme.of(context).textTheme.headline6,
                            ),
                            const SizedBox(top: 7),
                            Textual content(
                              activeMatches[index].chat![0].messages[0].message,
                              model: Theme.of(context).textTheme.bodyText2,
                            ),
                            const SizedBox(top: 3),
                            Textual content(
                              activeMatches[index].chat![0].messages[0].timeString,
                              model: Theme.of(context).textTheme.bodyText2,
                            ),
                          ],
                        ),
                      ],
                    ),
                  );
                }
              )
            ],
          ),
        ),
      ),
    );
  }
} 

Chat display is trying like this.

[ad_2]

RELATED ARTICLES

Most Popular

Recent Comments