Home > Enterprise >  Flutter Game extreme slow
Flutter Game extreme slow

Time:04-11

Im writing a TokenHunting game.
Im Having problem mixing QRCode reader and Google Maps on the same XamarinForms app then yersterday switched to Flutter, Im completely new to it and just started learning it.
After a lot of research I reach on the result below but it is really slow and with a black screen between screen transitions, Im almost sure that i did something wrong.
Im open to sugestions.

StackOverflow dont allow big block of code then there is a pastebin:

TokenHunter PASTEBIN source code

import 'dart:developer';
import 'dart:ffi';
import 'dart:io';
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:mobile_scanner/mobile_scanner.dart';

class WidgetsProvider {
  
  static StatefulWidget getScreenInstance(AppScreen _appScreen, SharedState _sharedState) {
    StatefulWidget _statefulWidget = ScreenHome(sharedState:_sharedState);
    _sharedState.screen = _appScreen;
    switch (_appScreen) {
      case AppScreen.AgeVerificationScreen: _statefulWidget = ScreenAgeVerification(sharedState:_sharedState); break;
      case AppScreen.Home: _statefulWidget = ScreenHome(sharedState:_sharedState); break;
      case AppScreen.Profile: _statefulWidget = ScreenProfile(sharedState:_sharedState); break;
      case AppScreen.Statement: _statefulWidget = ScreenStatement(sharedState:_sharedState); break;
      case AppScreen.Deposit: _statefulWidget = ScreenDeposit(sharedState:_sharedState); break;
      case AppScreen.Play: _statefulWidget = ScreenPlay(sharedState:_sharedState); break;
      case AppScreen.Login: _statefulWidget = ScreenLogin(sharedState:_sharedState); break;
      case AppScreen.Logout: _statefulWidget = ScreenLogout(sharedState:_sharedState); break;
      case AppScreen.Search: _statefulWidget = ScreenHome(sharedState:_sharedState); break;
    }
    return _statefulWidget;
  }
  
  static Route<dynamic> getRouter(
      BuildContext _context, AppScreen _screenTarget, SharedState _sharedState) {
    return MaterialPageRoute(
        builder: (context) => getScreenInstance(_screenTarget, _sharedState));
  }
  
  static VoidCallback getNavigator(
      BuildContext _context, AppScreen _screenTarget, SharedState _sharedState) {
    _sharedState.navigatingScreen = _screenTarget;
    late VoidCallback vc;
    vc = () {
      Navigator.pushAndRemoveUntil(
          _context,
          WidgetsProvider.getRouter(_context, _screenTarget, _sharedState),
              (route) => false
      );
    };
    return vc;;
  }...........

CodePudding user response:

It is an old problem with flutter, its since 2019 as you can see here:
https://github.com/flutter/flutter/issues/39797
As you can see there too they arent to fix it, Xamarin evolved a lot and is coming the MAUI too, I advise you go back to Xamarin, its impossible to fix it on Flutter.
MAIU is going to a much better alternative and mix barcode scanning with map will be a piece of cake there.

CodePudding user response:

You don't need to move to Xamarin Forms as @Bill told, just fix the navigation.
You can use one of following:

https://github.com/nubank/nuvigator
https://vrouter.dev/

  • Related