lundi 1 novembre 2021

Navigator operation requested with a context that does not include a Navigator in flutter web

I was just put official Doc code for see how Navigation work in web(chrome). But when I click button I get an error-> Navigator operation requested with a context that does not include a Navigator.

code->

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('First Route'),
        ),
        body: Center(
          child: ElevatedButton(
              child: Text('Open route'),
              // Within the `FirstRoute` widget
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => SecondRoute()),
                );
              }),
        ),
      ),
    );
  }
}

class SecondRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Second Route"),
      ),
      body: Center(
        child: ElevatedButton(
          // Within the SecondRoute widget
          onPressed: () {
            Navigator.pop(context);
          },
          child: Text('Go back!'),
        ),
      ),
    );
  }
}

Thanks...




what are the method to check website page speed?

What are the methods to check the website page speed? I Check on google to find out the solutions but all the solutions were paid for. I am looking for the free version where it shows me all the errors of the website.




Where to put the device detection logic? backend or frontend?

the front-end can request different apis on desktop and mobile. or request the same api, make the backend to distinct the different devices. is there any practices? any pros or cons?




Lighthouse returned error: PROTOCOL_TIMEOUT. Waiting for DevTools protocol response has exceeded the allotted time

I have developed a website which is working OK on desktop, but it is not working fine on mobile devices. Basically, it is taking an infinite time to load some pages. This is the error I got when I checked on page speed insights Lighthouse returned error:

PROTOCOL_TIMEOUT.   
Waiting for DevTools protocol response has exceeded the allotted time.   
(Method: Network.emulateNetworkConditions) (PROTOCOL_TIMEOUT). 



dimanche 31 octobre 2021

How can I securely transfer large amounts of files uploaded onto an API server hosted on a VPS to a dedicated file server?

The files will primarily be images and webms, potentially zip files <100MB. The time frame should be almost real time or within a few seconds.




Number of free dynos running

So, after my research on stackoverflow and other portals, I have not found any answer to the below question. I am using a free Heroku account without any kind of payments. If I run, say 2, applications on the free account, does it mean that I am using 2 dynos. Because I know that two dynos will consume double the dyno hours(If both the applications never sleep. I am aware of these basics of Heroku), and so this is a concern for me.




Flutter's ListView.builder with custom controller will not respond to PageUp/PageDown key events on the web

If I create a long list in Flutter Web with a ListView.builder, I get the mouse wheel events and the PageUp/PageDown keyboard events working fine. If I specify a custom ScrollController, the PageUp/PageDown keyboard events are no longer captured. How can I fix that? Here's a simple example

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late ScrollController _controller;

  @override
  void initState() {
    _controller = ScrollController();
    super.initState();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
          child: ListView.builder(
              itemCount: 500,
              controller: _controller, // will not respond to PageUp, PageDown
              itemBuilder: (BuildContext context, int i) => Text('Item $i'))),
    );
  }
}

If you comment out the controller: _controller line, the PageUp/PageDown presses work.

Is this a bug? If not, what do I need to do to my custom controller to respond to PageUp/PageDown?

Thank you for your help, Tony