问:
Flutter-> TextField hidden by KeyBoard
i have a problem, when i'm focusing on a TextFormField, my keyBoard come over this one. I have tried so much differents ways.
I have found one single solution but my view begin from the bottom to the top and i want the opposite.
I hope someone got a solution to auto scroll the TextFormField, thank you ! </p>

<p>My code here : </p>

```<code>  final _formKey = GlobalKey<FormState>();

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    nomController.dispose();
    adresseController.dispose();
    complementAdresseController.dispose();
    villeController.dispose();
    codePostalController.dispose();
    super.dispose();
  }

  //controller for get value from TextFormField
  TextEditingController nomController = TextEditingController();
  TextEditingController adresseController = TextEditingController();
  TextEditingController complementAdresseController = TextEditingController();
  TextEditingController villeController = TextEditingController();
  TextEditingController codePostalController = TextEditingController();

  //save value in variables for send data from http request
  String nom;
  String adresse;
  String complement;
  String ville;
  String codePostal;

  final ScrollController _scrollController = ScrollController();

  sendFormData() async {
    var postUri = Uri.parse("http://51.158.67.16:8000/api/contact/");
    var request = new http.MultipartRequest("POST", postUri);
    request.fields['name'] = nom;
    request.fields['adresse'] = adresse;
    request.fields['complement'] = complement;
    request.fields['city'] = ville;
    request.fields['postalCode'] = codePostal;

    print(nom);
    print(adresse);
    print(complement);
    print(ville);
    print(codePostal);

    request.send().then((response) {
      if (response.statusCode == 201) {
        print("Uploaded!");
      } else {
        print(response.statusCode);
      }
    });
  }

  validateAndSave() async {
    final form = _formKey.currentState;
    if (form.validate()) {
      setState(() {
        nom = nomController.text;
        adresse = adresseController.text;
        complement = complementAdresseController.text;
        ville = villeController.text;
        codePostal = codePostalController.text;
      });

      await sendFormData();
    } else {
      print('form is invalid');
    }
  }

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
        child: SafeArea(
            top: false,
            bottom: false,
            child: Container(
                color: Color.fromRGBO(22, 22, 22, 1.0),
                child: Column(children: <Widget>[
                  Container(
                    margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
                    child: Text(
                      'Veuillez remplir les champs si dessous afin de nous communiquer l\'emplacement et le nom du monument ou de l\'oeuvre',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 16,
                        fontFamily: 'Nunito',
                      ),
                    ),
                  ),
                  Form(
                      key: _formKey,
                      child: Column(
                        children: <Widget>[
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Nom de l’oeuvre",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Container(
                            height: MediaQuery.of(context).size.height / 13,
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(10.0))),
                            padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                            child: new TextFormField(
                              style: TextStyle(color: Colors.white),
                              controller: nomController,
                              onChanged: (value) {
                                setState(() {
                                  nom = value;
                                });
                              },
                              validator: (value) {
                                if (value.length <= 4) {
                                  showDialog(
                                      barrierDismissible: false,
                                      context: context,
                                      builder: (_) => AlertDialog(
                                            backgroundColor:
                                                Color.fromRGBO(40, 40, 40, 1.0),
                                            titleTextStyle:
                                                TextStyle(color: Colors.white),
                                            title: Text(
                                                "Le nom doit contenir au minimum 4 lettres"),
                                            actions: <Widget>[
                                              FlatButton(
                                                onPressed: () =>
                                                    Navigator.pop(context),
                                                child: Text('OK',
                                                    style: TextStyle(
                                                        fontSize: 18,
                                                        color: Colors.white)),
                                              )
                                            ],
                                          ));
                                }
                                return null;
                              },
                              textAlign: TextAlign.left,
                              decoration: InputDecoration(
                                  contentPadding: EdgeInsets.symmetric(
                                      vertical: 0, horizontal: 10),
                                  hintStyle: TextStyle(
                                      color: Color.fromRGBO(133, 133, 133, 1.0),
                                      fontSize: 16),
                                  suffixIcon: Icon(Icons.search,
                                      color:
                                          Color.fromRGBO(133, 133, 133, 1.0)),
                                  hintText: 'Nom du monument, oeuvre...',
                                  fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                  filled: true,
                                  border: OutlineInputBorder(
                                    borderSide: BorderSide.none,
                                    borderRadius: BorderRadius.circular(10.0),
                                  )),
                            ),
                          ),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Adresse",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Container(
                            height: MediaQuery.of(context).size.height / 13,
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(10.0))),
                            padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                            child: TextFormField(
                              style: TextStyle(color: Colors.white),
                              controller: adresseController,
                              onChanged: (value) {
                                setState(() {
                                  adresse = value;
                                });
                              },
                              textAlign: TextAlign.left,
                              decoration: InputDecoration(
                                  contentPadding: EdgeInsets.symmetric(
                                      vertical: 0, horizontal: 10),
                                  hintStyle: TextStyle(
                                      color: Color.fromRGBO(133, 133, 133, 1.0),
                                      fontSize: 16),
                                  suffixIcon: Icon(
                                    Icons.search,
                                    color: Color.fromRGBO(133, 133, 133, 1.0),
                                  ),
                                  hintText: '( Optionnel ) Adresse',
                                  fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                  filled: true,
                                  border: OutlineInputBorder(
                                    borderSide: BorderSide.none,
                                    borderRadius: BorderRadius.circular(10.0),
                                  )),
                            ),
                          ),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Complément d'adresse",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Container(
                            height: MediaQuery.of(context).size.height / 13,
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(10.0))),
                            padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                            child: TextFormField(
                              style: TextStyle(color: Colors.white),
                              controller: complementAdresseController,
                              onChanged: (value) {
                                setState(() {
                                  complement = value;
                                });
                              },
                              decoration: InputDecoration(
                                  contentPadding: EdgeInsets.symmetric(
                                      vertical: 0, horizontal: 10),
                                  hintStyle: TextStyle(
                                      color: Color.fromRGBO(133, 133, 133, 1.0),
                                      fontSize: 16),
                                  suffixIcon: Icon(Icons.search,
                                      color:
                                          Color.fromRGBO(133, 133, 133, 1.0)),
                                  hintText: '(Optionnel) Complement d’adresse',
                                  fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                  filled: true,
                                  border: OutlineInputBorder(
                                    borderSide: BorderSide.none,
                                    borderRadius: BorderRadius.circular(10.0),
                                  )),
                            ),
                          ),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Ville",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Container(
                                height: MediaQuery.of(context).size.height / 13,
                                width: MediaQuery.of(context).size.width / 1.5,
                                decoration: BoxDecoration(
                                    borderRadius: BorderRadius.all(
                                        Radius.circular(10.0))),
                                padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                                child: TextFormField(
                                  style: TextStyle(color: Colors.white),
                                  controller: villeController,
                                  onChanged: (value) {
                                    setState(() {
                                      ville = value;
                                    });
                                  },
                                  validator: (value) {
                                    if (value.length <= 2) {
                                      showDialog(
                                          barrierDismissible: false,
                                          context: context,
                                          builder: (_) => AlertDialog(
                                                  backgroundColor:
                                                      Color.fromRGBO(
                                                          40, 40, 40, 1.0),
                                                  titleTextStyle: TextStyle(
                                                      color: Colors.white),
                                                  title: Text(
                                                      "La ville doit contenir au minimum 2 lettres"),
                                                  actions: <Widget>[
                                                    FlatButton(
                                                      onPressed: () =>
                                                          Navigator.pop(
                                                              context),
                                                      child: Text('OK',
                                                          style: TextStyle(
                                                              fontSize: 18,
                                                              color: Colors
                                                                  .white)),
                                                    )
                                                  ]));
                                    }
                                    return null;
                                  },
                                  decoration: InputDecoration(
                                      contentPadding: EdgeInsets.symmetric(
                                          vertical: 0, horizontal: 10),
                                      hintStyle: TextStyle(
                                          color: Color.fromRGBO(
                                              133, 133, 133, 1.0),
                                          fontSize: 16),
                                      suffixIcon: Icon(Icons.search,
                                          color: Color.fromRGBO(
                                              133, 133, 133, 1.0)),
                                      hintText: 'Ville',
                                      fillColor:
                                          Color.fromRGBO(40, 40, 40, 1.0),
                                      filled: true,
                                      border: OutlineInputBorder(
                                        borderSide: BorderSide.none,
                                        borderRadius:
                                            BorderRadius.circular(10.0),
                                      )),
                                ),
                              )),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Code Postal",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Container(
                                height: MediaQuery.of(context).size.height / 13,
                                width: MediaQuery.of(context).size.width / 1.5,
                                decoration: BoxDecoration(
                                    borderRadius: BorderRadius.all(
                                        Radius.circular(10.0))),
                                padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                                child: TextFormField(
                                  style: TextStyle(color: Colors.white),
                                  controller: codePostalController,
                                  onChanged: (value) {
                                    setState(() {
                                      codePostal = value;
                                    });
                                  },
                                  validator: (value) {
                                    if (value.length != 5) {
                                      showDialog(
                                          barrierDismissible: false,
                                          context: context,
                                          builder: (_) => AlertDialog(
                                                  backgroundColor:
                                                      Color.fromRGBO(
                                                          40, 40, 40, 1.0),
                                                  titleTextStyle: TextStyle(
                                                      color: Colors.white),
                                                  title: Text(
                                                      "Le code postal doit contenir 5 chiffres"),
                                                  actions: <Widget>[
                                                    FlatButton(
                                                      onPressed: () =>
                                                          Navigator.pop(
                                                              context),
                                                      child: Text('OK',
                                                          style: TextStyle(
                                                              fontSize: 18,
                                                              color: Colors
                                                                  .white)),
                                                    )
                                                  ]));
                                    }
                                    return null;
                                  },
                                  keyboardType: TextInputType.number,
                                  decoration: InputDecoration(
                                    contentPadding: EdgeInsets.symmetric(
                                        vertical: 0, horizontal: 10),
                                    hintStyle: TextStyle(
                                        color:
                                            Color.fromRGBO(133, 133, 133, 1.0),
                                        fontSize: 16),
                                    border: OutlineInputBorder(
                                      borderSide: BorderSide.none,
                                      borderRadius: BorderRadius.circular(10.0),
                                    ),
                                    suffixIcon: Icon(Icons.search,
                                        color:
                                            Color.fromRGBO(133, 133, 133, 1.0)),
                                    hintText: 'Code postal',
                                    fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                    filled: true,
                                  ),
                                ),
                              )),
                          FlatButton(
                              color: Colors.transparent,
                              shape: RoundedRectangleBorder(
                                  borderRadius: BorderRadius.circular(10.0)),
                              onPressed: () async {
                                await validateAndSave();
                              },
                              textColor: Colors.white,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(0, 20, 0, 60),
                                child: Container(
                                  alignment: Alignment(0, 0),
                                  width: MediaQuery.of(context).size.width / 2,
                                  height: 65,
                                  decoration: const BoxDecoration(
                                      borderRadius: BorderRadius.all(
                                          Radius.circular(10.0)),
                                      color:
                                          Color.fromRGBO(243, 243, 243, 1.0)),
                                  child: Text(
                                    'ENVOYER',
                                    style: TextStyle(
                                        fontSize: 18,
                                        color: Color.fromRGBO(40, 40, 40, 1.0)),
                                  ),

                                  //padding: EdgeInsets.fromLTRB(0, 53, 0, 20),
                                ),
                              )),
                        ],
                      ))
                ]))));
  }
}```
</code>```

答:
//Add this line "resizeToAvoidBottomInset: true," to your Scaffold and put your main container in ScrollView.</p>

```<code>   @override
   Widget build(BuildContext context) {
   return Scaffold(
   resizeToAvoidBottomInset: true,
   key: _scaffoldKey,
   backgroundColor: Colors.white,
   body: SingleChildScrollView(
      child: Container()
   ),
  );
 }
</code>```

Title: Flutter-> TextField hidden by KeyBoard

Body:
i have a problem, when i'm focusing on a TextFormField, my keyBoard come over this one. I have tried so much differents ways.
I have found one single solution but my view begin from the bottom to the top and i want the opposite.
I hope someone got a solution to auto scroll the TextFormField, thank you !

My code here :

  final _formKey = GlobalKey<FormState>();

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    nomController.dispose();
    adresseController.dispose();
    complementAdresseController.dispose();
    villeController.dispose();
    codePostalController.dispose();
    super.dispose();
  }

  //controller for get value from TextFormField
  TextEditingController nomController = TextEditingController();
  TextEditingController adresseController = TextEditingController();
  TextEditingController complementAdresseController = TextEditingController();
  TextEditingController villeController = TextEditingController();
  TextEditingController codePostalController = TextEditingController();

  //save value in variables for send data from http request
  String nom;
  String adresse;
  String complement;
  String ville;
  String codePostal;

  final ScrollController _scrollController = ScrollController();

  sendFormData() async {
    var postUri = Uri.parse("http://51.158.67.16:8000/api/contact/");
    var request = new http.MultipartRequest("POST", postUri);
    request.fields['name'] = nom;
    request.fields['adresse'] = adresse;
    request.fields['complement'] = complement;
    request.fields['city'] = ville;
    request.fields['postalCode'] = codePostal;

    print(nom);
    print(adresse);
    print(complement);
    print(ville);
    print(codePostal);

    request.send().then((response) {
      if (response.statusCode == 201) {
        print("Uploaded!");
      } else {
        print(response.statusCode);
      }
    });
  }

  validateAndSave() async {
    final form = _formKey.currentState;
    if (form.validate()) {
      setState(() {
        nom = nomController.text;
        adresse = adresseController.text;
        complement = complementAdresseController.text;
        ville = villeController.text;
        codePostal = codePostalController.text;
      });

      await sendFormData();
    } else {
      print('form is invalid');
    }
  }

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
        child: SafeArea(
            top: false,
            bottom: false,
            child: Container(
                color: Color.fromRGBO(22, 22, 22, 1.0),
                child: Column(children: <Widget>[
                  Container(
                    margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
                    child: Text(
                      'Veuillez remplir les champs si dessous afin de nous communiquer l\'emplacement et le nom du monument ou de l\'oeuvre',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 16,
                        fontFamily: 'Nunito',
                      ),
                    ),
                  ),
                  Form(
                      key: _formKey,
                      child: Column(
                        children: <Widget>[
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Nom de l’oeuvre",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Container(
                            height: MediaQuery.of(context).size.height / 13,
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(10.0))),
                            padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                            child: new TextFormField(
                              style: TextStyle(color: Colors.white),
                              controller: nomController,
                              onChanged: (value) {
                                setState(() {
                                  nom = value;
                                });
                              },
                              validator: (value) {
                                if (value.length <= 4) {
                                  showDialog(
                                      barrierDismissible: false,
                                      context: context,
                                      builder: (_) => AlertDialog(
                                            backgroundColor:
                                                Color.fromRGBO(40, 40, 40, 1.0),
                                            titleTextStyle:
                                                TextStyle(color: Colors.white),
                                            title: Text(
                                                "Le nom doit contenir au minimum 4 lettres"),
                                            actions: <Widget>[
                                              FlatButton(
                                                onPressed: () =>
                                                    Navigator.pop(context),
                                                child: Text('OK',
                                                    style: TextStyle(
                                                        fontSize: 18,
                                                        color: Colors.white)),
                                              )
                                            ],
                                          ));
                                }
                                return null;
                              },
                              textAlign: TextAlign.left,
                              decoration: InputDecoration(
                                  contentPadding: EdgeInsets.symmetric(
                                      vertical: 0, horizontal: 10),
                                  hintStyle: TextStyle(
                                      color: Color.fromRGBO(133, 133, 133, 1.0),
                                      fontSize: 16),
                                  suffixIcon: Icon(Icons.search,
                                      color:
                                          Color.fromRGBO(133, 133, 133, 1.0)),
                                  hintText: 'Nom du monument, oeuvre...',
                                  fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                  filled: true,
                                  border: OutlineInputBorder(
                                    borderSide: BorderSide.none,
                                    borderRadius: BorderRadius.circular(10.0),
                                  )),
                            ),
                          ),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Adresse",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Container(
                            height: MediaQuery.of(context).size.height / 13,
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(10.0))),
                            padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                            child: TextFormField(
                              style: TextStyle(color: Colors.white),
                              controller: adresseController,
                              onChanged: (value) {
                                setState(() {
                                  adresse = value;
                                });
                              },
                              textAlign: TextAlign.left,
                              decoration: InputDecoration(
                                  contentPadding: EdgeInsets.symmetric(
                                      vertical: 0, horizontal: 10),
                                  hintStyle: TextStyle(
                                      color: Color.fromRGBO(133, 133, 133, 1.0),
                                      fontSize: 16),
                                  suffixIcon: Icon(
                                    Icons.search,
                                    color: Color.fromRGBO(133, 133, 133, 1.0),
                                  ),
                                  hintText: '( Optionnel ) Adresse',
                                  fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                  filled: true,
                                  border: OutlineInputBorder(
                                    borderSide: BorderSide.none,
                                    borderRadius: BorderRadius.circular(10.0),
                                  )),
                            ),
                          ),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Complément d'adresse",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Container(
                            height: MediaQuery.of(context).size.height / 13,
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(10.0))),
                            padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                            child: TextFormField(
                              style: TextStyle(color: Colors.white),
                              controller: complementAdresseController,
                              onChanged: (value) {
                                setState(() {
                                  complement = value;
                                });
                              },
                              decoration: InputDecoration(
                                  contentPadding: EdgeInsets.symmetric(
                                      vertical: 0, horizontal: 10),
                                  hintStyle: TextStyle(
                                      color: Color.fromRGBO(133, 133, 133, 1.0),
                                      fontSize: 16),
                                  suffixIcon: Icon(Icons.search,
                                      color:
                                          Color.fromRGBO(133, 133, 133, 1.0)),
                                  hintText: '(Optionnel) Complement d’adresse',
                                  fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                  filled: true,
                                  border: OutlineInputBorder(
                                    borderSide: BorderSide.none,
                                    borderRadius: BorderRadius.circular(10.0),
                                  )),
                            ),
                          ),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Ville",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Container(
                                height: MediaQuery.of(context).size.height / 13,
                                width: MediaQuery.of(context).size.width / 1.5,
                                decoration: BoxDecoration(
                                    borderRadius: BorderRadius.all(
                                        Radius.circular(10.0))),
                                padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                                child: TextFormField(
                                  style: TextStyle(color: Colors.white),
                                  controller: villeController,
                                  onChanged: (value) {
                                    setState(() {
                                      ville = value;
                                    });
                                  },
                                  validator: (value) {
                                    if (value.length <= 2) {
                                      showDialog(
                                          barrierDismissible: false,
                                          context: context,
                                          builder: (_) => AlertDialog(
                                                  backgroundColor:
                                                      Color.fromRGBO(
                                                          40, 40, 40, 1.0),
                                                  titleTextStyle: TextStyle(
                                                      color: Colors.white),
                                                  title: Text(
                                                      "La ville doit contenir au minimum 2 lettres"),
                                                  actions: <Widget>[
                                                    FlatButton(
                                                      onPressed: () =>
                                                          Navigator.pop(
                                                              context),
                                                      child: Text('OK',
                                                          style: TextStyle(
                                                              fontSize: 18,
                                                              color: Colors
                                                                  .white)),
                                                    )
                                                  ]));
                                    }
                                    return null;
                                  },
                                  decoration: InputDecoration(
                                      contentPadding: EdgeInsets.symmetric(
                                          vertical: 0, horizontal: 10),
                                      hintStyle: TextStyle(
                                          color: Color.fromRGBO(
                                              133, 133, 133, 1.0),
                                          fontSize: 16),
                                      suffixIcon: Icon(Icons.search,
                                          color: Color.fromRGBO(
                                              133, 133, 133, 1.0)),
                                      hintText: 'Ville',
                                      fillColor:
                                          Color.fromRGBO(40, 40, 40, 1.0),
                                      filled: true,
                                      border: OutlineInputBorder(
                                        borderSide: BorderSide.none,
                                        borderRadius:
                                            BorderRadius.circular(10.0),
                                      )),
                                ),
                              )),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(18, 22, 0, 4),
                                child: Text(
                                  "Code Postal",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 16),
                                ),
                              )),
                          Align(
                              alignment: Alignment.centerLeft,
                              child: Container(
                                height: MediaQuery.of(context).size.height / 13,
                                width: MediaQuery.of(context).size.width / 1.5,
                                decoration: BoxDecoration(
                                    borderRadius: BorderRadius.all(
                                        Radius.circular(10.0))),
                                padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                                child: TextFormField(
                                  style: TextStyle(color: Colors.white),
                                  controller: codePostalController,
                                  onChanged: (value) {
                                    setState(() {
                                      codePostal = value;
                                    });
                                  },
                                  validator: (value) {
                                    if (value.length != 5) {
                                      showDialog(
                                          barrierDismissible: false,
                                          context: context,
                                          builder: (_) => AlertDialog(
                                                  backgroundColor:
                                                      Color.fromRGBO(
                                                          40, 40, 40, 1.0),
                                                  titleTextStyle: TextStyle(
                                                      color: Colors.white),
                                                  title: Text(
                                                      "Le code postal doit contenir 5 chiffres"),
                                                  actions: <Widget>[
                                                    FlatButton(
                                                      onPressed: () =>
                                                          Navigator.pop(
                                                              context),
                                                      child: Text('OK',
                                                          style: TextStyle(
                                                              fontSize: 18,
                                                              color: Colors
                                                                  .white)),
                                                    )
                                                  ]));
                                    }
                                    return null;
                                  },
                                  keyboardType: TextInputType.number,
                                  decoration: InputDecoration(
                                    contentPadding: EdgeInsets.symmetric(
                                        vertical: 0, horizontal: 10),
                                    hintStyle: TextStyle(
                                        color:
                                            Color.fromRGBO(133, 133, 133, 1.0),
                                        fontSize: 16),
                                    border: OutlineInputBorder(
                                      borderSide: BorderSide.none,
                                      borderRadius: BorderRadius.circular(10.0),
                                    ),
                                    suffixIcon: Icon(Icons.search,
                                        color:
                                            Color.fromRGBO(133, 133, 133, 1.0)),
                                    hintText: 'Code postal',
                                    fillColor: Color.fromRGBO(40, 40, 40, 1.0),
                                    filled: true,
                                  ),
                                ),
                              )),
                          FlatButton(
                              color: Colors.transparent,
                              shape: RoundedRectangleBorder(
                                  borderRadius: BorderRadius.circular(10.0)),
                              onPressed: () async {
                                await validateAndSave();
                              },
                              textColor: Colors.white,
                              child: Padding(
                                padding: EdgeInsets.fromLTRB(0, 20, 0, 60),
                                child: Container(
                                  alignment: Alignment(0, 0),
                                  width: MediaQuery.of(context).size.width / 2,
                                  height: 65,
                                  decoration: const BoxDecoration(
                                      borderRadius: BorderRadius.all(
                                          Radius.circular(10.0)),
                                      color:
                                          Color.fromRGBO(243, 243, 243, 1.0)),
                                  child: Text(
                                    'ENVOYER',
                                    style: TextStyle(
                                        fontSize: 18,
                                        color: Color.fromRGBO(40, 40, 40, 1.0)),
                                  ),

                                  //padding: EdgeInsets.fromLTRB(0, 53, 0, 20),
                                ),
                              )),
                        ],
                      ))
                ]))));
  }
}```

Body:
//Add this line "resizeToAvoidBottomInset: true," to your Scaffold and put your main container in ScrollView.

   @override
   Widget build(BuildContext context) {
   return Scaffold(
   resizeToAvoidBottomInset: true,
   key: _scaffoldKey,
   backgroundColor: Colors.white,
   body: SingleChildScrollView(
      child: Container()
   ),
  );
 }


来源: stackexchange

问:
Using React-file-viewer
I'm trying to use React-file-viewer. Npm tutorial is here
But I have an error in the console : "you may need an appropriate loader to handle this file type"
This is my code :

```<code>import FileViewer from 'react-file-viewer';
import { CustomErrorComponent } from 'custom-error';
const file = 'http://example.com/image.png'
const type = 'png'

 onError = (e) => {
    logger.logError(e, 'error in file-viewer');
 }

 <FileViewer
 fileType={type}
 filePath={file}
 errorComponent={CustomErrorComponent}
 onError={this.onError}/>
</code>```

I specify, i have babel-preset-es2015 and i use it

How can I do ?
Thank you

答:
You need to import logger from Logging library,
something like this:

```<code>import logger from 'logging-Lib';
</code>```

see more:
https://www.npmjs.com/package/react-file-viewer

ContentLicense: CC BY-SA 3.0

Title: Using React-file-viewer

Body:
I'm trying to use React-file-viewer. Npm tutorial is here
But I have an error in the console : "you may need an appropriate loader to handle this file type"
This is my code :

import FileViewer from 'react-file-viewer';
import { CustomErrorComponent } from 'custom-error';
const file = 'http://example.com/image.png'
const type = 'png'

 onError = (e) => {
    logger.logError(e, 'error in file-viewer');
 }

 <FileViewer
 fileType={type}
 filePath={file}
 errorComponent={CustomErrorComponent}
 onError={this.onError}/>

I specify, i have babel-preset-es2015 and i use it

How can I do ?
Thank you

Body:
You need to import logger from Logging library,
something like this:

import logger from 'logging-Lib';

see more:
https://www.npmjs.com/package/react-file-viewer

ContentLicense: CC BY-SA 4.0


问:
How to stay updated as an Android Developer?
I'm an Android Developer with more than 7 years in the software industry. Right now I'm at a point where my knowledge is outdated and I'm looking for a way to get updated with all the recent changes and trends.</p>

答:
You have several options:

Answer other people's questions on stack overflow. Most of the time they are questions you will never ask yourself.

Try out the new android apis, and look for quirks... Android compatibility issues are a ... (no good word for it)

Look through google play at apps you did not develop, and try to figure out how they work (code wise)

Try writing automated tests for apps you did not write, to see how that works.


问:
JMeter - Api GET Request - Response says: No known way to render data, Status Code is 200 though
Performing GET Requests which returns a JSON response.
JMeter is getting Statua code 200 but in Response, it says: NO way found to render data.
I tried the same request in POSTMAN and it is working fine.

答:
We are not telepathic enough to state why exactly request in Postman works and request in JMeter doesn't, in general the answer would be: you're not sending the same requests.

Double check the following:

Request URL, if request parameters have some non-ASCII data it needs to be url-encoded

Request headers, in particular Content-Type. In JMeter request headers can be added/modified using HTTP Header Manager

Request body (if any), again encoding might be very important

In general given your request works in Postman you can just record it using JMeter's HTTP(S) Test Script Recorder

Start JMeter's HTTP(S) Test Script Recorder

Configure Postman to use JMeter as the proxy

Run your request in Postman

That's it, JMeter should capture the request under the Recording Controller


问:
x86 Assembly: Loops!
Okay, long story short, I'm learning assembly, and I'm trying to make a loop print out the ascii characters "0" - "9".
So, I did all of the basics I've been seeing in examples, like saving register states with pushad and popad, allocating stack space, and making sure I leave things the way they started.
So I managed this small example:

```<code>;
; Hello_World.asm
; (NASM Syntax, Windows)

    extern _printf

    section .text

_main:
  pushad                ; save register states

  push  ebp             ; save old stack
  mov       ebp, esp    ; prepare new stack
  sub       esp, 1*4    ; allocate 4 bytes

  mov       byte [esp + 0], 48  ; add ascii '0' to stack
  mov       byte [esp + 1], 0   ; add ascii NULL terminator to stack

  push  esp;        ; push the string in the stacks refrence
  call  _printf     ; call printf()
  add   esp, 4      ; pop string refrence

  add   esp, 1*4    ; deallocate 4 bytes
  mov   esp, ebp    ; close this stack
  pop   ebp         ; restore old stack

  popad             ; restore register states
  ret               ; leave this function
</code>```

This works, it prints out '0', but that's a little on the safe side. I tried adding a loop into it, but things just fall apart there. I read that the 'loop' opcode is supposed to decrement the ECX register, and go back to the label parameter should ECX > 0, however, I don't think I've quite got it yet.

So I add a few lines, and come up with this:

```<code>;
; Hello_World.asm
;

    extern _printf
    global _main

    section .text

_main:
  pushad                ; save register states

  push  ebp         ; save old stack
  mov   ebp, esp    ; prepare new stack
  sub   esp, 1*4    ; allocate 4 bytes

  mov   byte [esp + 0], 48  ; add ascii '0' to stack
  mov   byte [esp + 1], 0   ; add ascii NULL terminator to stack

  mov   ecx, 9      ; set loop counter to 9

aLoop:
  inc   byte [esp + 0]  ; increment ascii character
  push  esp;        ; push the string in the stacks refrence
  call  _printf     ; call printf()
  add   esp, 4      ; pop string refrence
  loop  aLoop           ; loop back to aLoop if ecx > 0

  add   esp, 1*4    ; deallocate 4 bytes
  mov   esp, ebp    ; close this stack
  pop   ebp         ; restore old stack

  popad             ; restore register states
  ret                   ; leave this function
</code>```

Well, now things go crazy. I run it in command prompt and I hear this beeping through my headphones, and it's cycling through every ascii character, printing them all out. So after about 5 seconds of flying characters, I assume something overflows, and it just crashes.

I'm pretty new to assembly (today's my first day of real coding), and I don't see what's going wrong. Could someone please explain how I could better implement a loop ?

Thanks ahead!
-Jason

答:
```<code>aLoop:
  inc   byte [esp + 0]  ; increment ascii character
  push  ecx;        ; save ecx
  push  esp;        ; push the string in the stacks refrence
  call  printf     ; call printf()
  add   esp, 4      ; pop string refrence
  pop   ecx
  loop  aLoop           ; loop back to aLoop if ecx > 0
</code>```

The caller-saved registers are eax, ecx, edx. The called subroutine is allowed to modify these registers. Look for caller-saved vs callee-saved registers using a search engine. Should give you more details.

Title: x86 Assembly: Loops!

Body:
Okay, long story short, I'm learning assembly, and I'm trying to make a loop print out the ascii characters "0" - "9".
So, I did all of the basics I've been seeing in examples, like saving register states with pushad and popad, allocating stack space, and making sure I leave things the way they started.
So I managed this small example:

;
; Hello_World.asm
; (NASM Syntax, Windows)

    extern _printf

    section .text

_main:
  pushad                ; save register states

  push  ebp             ; save old stack
  mov       ebp, esp    ; prepare new stack
  sub       esp, 1*4    ; allocate 4 bytes

  mov       byte [esp + 0], 48  ; add ascii '0' to stack
  mov       byte [esp + 1], 0   ; add ascii NULL terminator to stack

  push  esp;        ; push the string in the stacks refrence
  call  _printf     ; call printf()
  add   esp, 4      ; pop string refrence

  add   esp, 1*4    ; deallocate 4 bytes
  mov   esp, ebp    ; close this stack
  pop   ebp         ; restore old stack

  popad             ; restore register states
  ret               ; leave this function

This works, it prints out '0', but that's a little on the safe side. I tried adding a loop into it, but things just fall apart there. I read that the 'loop' opcode is supposed to decrement the ECX register, and go back to the label parameter should ECX > 0, however, I don't think I've quite got it yet.

So I add a few lines, and come up with this:

;
; Hello_World.asm
;

    extern _printf
    global _main

    section .text

_main:
  pushad                ; save register states

  push  ebp         ; save old stack
  mov   ebp, esp    ; prepare new stack
  sub   esp, 1*4    ; allocate 4 bytes

  mov   byte [esp + 0], 48  ; add ascii '0' to stack
  mov   byte [esp + 1], 0   ; add ascii NULL terminator to stack

  mov   ecx, 9      ; set loop counter to 9

aLoop:
  inc   byte [esp + 0]  ; increment ascii character
  push  esp;        ; push the string in the stacks refrence
  call  _printf     ; call printf()
  add   esp, 4      ; pop string refrence
  loop  aLoop           ; loop back to aLoop if ecx > 0

  add   esp, 1*4    ; deallocate 4 bytes
  mov   esp, ebp    ; close this stack
  pop   ebp         ; restore old stack

  popad             ; restore register states
  ret                   ; leave this function

Well, now things go crazy. I run it in command prompt and I hear this beeping through my headphones, and it's cycling through every ascii character, printing them all out. So after about 5 seconds of flying characters, I assume something overflows, and it just crashes.

I'm pretty new to assembly (today's my first day of real coding), and I don't see what's going wrong. Could someone please explain how I could better implement a loop ?

Thanks ahead!
-Jason

Body:
aLoop:
  inc   byte [esp + 0]  ; increment ascii character
  push  ecx;        ; save ecx
  push  esp;        ; push the string in the stacks refrence
  call  printf     ; call printf()
  add   esp, 4      ; pop string refrence
  pop   ecx
  loop  aLoop           ; loop back to aLoop if ecx > 0

The caller-saved registers are eax, ecx, edx. The called subroutine is allowed to modify these registers. Look for caller-saved vs callee-saved registers using a search engine. Should give you more details.


问:
Nodejs loops iterating before executing the mysql queries embedded inside them
I am unable to return the projectIds array after the mysql statements have finished executing as the loop is iterating before executing them. This results in empty array being returned everytime.

```<code>function fetchProjects (projects, userId, callback) {
  projectIds = [];
    Object.keys(projects).forEach(function(key) {
      var row = projects[key];
      const sql = 'create table if not exists users_' + row.project_id + '(sno int primary key auto_increment, iteration_no int not null, user_id int not null, foreign key(iteration_no) references pro_' + row.project_id + '(iteration_no), foreign key(user_id) references user(user_id))';
      connection.query(sql, function(err, result) {
        if(err) {
          console.log(err.sqlMessage);
          return callback(err.sqlMessage, false);
        } else {
          // console.log("First statement executed");
          const sql1 = "select distinct t1.project_id, t1.project_name, t1.client, t1.initial_department_id, t1.start_date, t1.status, t1.current_department, t1.currently_assigned_user from project t1, users_" + row.project_id + " t2 where t1.project_id = '" + row.project_id + "' and (select user_id from users_" + row.project_id +" where user_id = " + userId + ")";
          connection.query(sql1, function(err, result1) {
            if(err) {
              console.log(err.sqlMessage);
              return callback(err.sqlMessage, false);
            } else {
              if(result1.length > 0) {
                console.log(result1);
                projectIds.push(result1);
              }
            }
          });
        }
      });
      // console.log("Iterating");
    });
    return callback(false, projectIds);
}
</code>```

答:
You are trying to execute callback style code in forEach which doesn't wait for the query to finish. That is the reason you are getting emoty array. I would make few modifications

Use promise version of the query method. Check the documentation of mysql node package

Use for..of loop instead of forEach.

Make the function async

Also await when you call the promise version of query method.

Hope this helps.

Body:
I am unable to return the projectIds array after the mysql statements have finished executing as the loop is iterating before executing them. This results in empty array being returned everytime.

function fetchProjects (projects, userId, callback) {
  projectIds = [];
    Object.keys(projects).forEach(function(key) {
      var row = projects[key];
      const sql = 'create table if not exists users_' + row.project_id + '(sno int primary key auto_increment, iteration_no int not null, user_id int not null, foreign key(iteration_no) references pro_' + row.project_id + '(iteration_no), foreign key(user_id) references user(user_id))';
      connection.query(sql, function(err, result) {
        if(err) {
          console.log(err.sqlMessage);
          return callback(err.sqlMessage, false);
        } else {
          // console.log("First statement executed");
          const sql1 = "select distinct t1.project_id, t1.project_name, t1.client, t1.initial_department_id, t1.start_date, t1.status, t1.current_department, t1.currently_assigned_user from project t1, users_" + row.project_id + " t2 where t1.project_id = '" + row.project_id + "' and (select user_id from users_" + row.project_id +" where user_id = " + userId + ")";
          connection.query(sql1, function(err, result1) {
            if(err) {
              console.log(err.sqlMessage);
              return callback(err.sqlMessage, false);
            } else {
              if(result1.length > 0) {
                console.log(result1);
                projectIds.push(result1);
              }
            }
          });
        }
      });
      // console.log("Iterating");
    });
    return callback(false, projectIds);
}


问:
NET::ERR_CERT_COMMON_NAME_INVALID - Error Message
I built a website some time ago with Flask. Now all of a sudden when I try to navigate there I get the following:

NET::ERR_CERT_COMMON_NAME_INVALID

Your connection is not private
Attackers might be trying to steal your information from www.mysite.org (for example, passwords, messages, or credit cards). Learn more

Does anyone know what's going on?

答:
For Chrome 58 and later, only the subjectAlternativeName extension, not commonName, is used to match the domain name and site certificate. So, if you are missing the Subject Alternative Name in your certificate then you will experience the NET::ERR_CERT_COMMON_NAME_INVALID error.

In order to have a Subject Alternate Name (SAN) on an SSL certificate, you must first edit your OpenSSL configuration. On Ubuntu/Debian, that can be found at /etc/ssl/openssl.cnf Find the section of that file with the heading [ v3_ca ], you can add the line with your SAN there:

```<code>subjectAltName = www.example.com
</code>```

Body:
For Chrome 58 and later, only the subjectAlternativeName extension, not commonName, is used to match the domain name and site certificate. So, if you are missing the Subject Alternative Name in your certificate then you will experience the NET::ERR_CERT_COMMON_NAME_INVALID error.

In order to have a Subject Alternate Name (SAN) on an SSL certificate, you must first edit your OpenSSL configuration. On Ubuntu/Debian, that can be found at /etc/ssl/openssl.cnf Find the section of that file with the heading [ v3_ca ], you can add the line with your SAN there:

subjectAltName = www.example.com


问:
apply a custom numba njit function to pandas rolling object
With the pandas 1.0.0 release, .apply now has the ability to use numba jit functions.

Is there a way to take advantage of this .apply functionality when using .rolling ?

For example I have a pandas.DataFrame, and a numba_mean function I would like to apply to get a rolling mean of 3 periods.

```<code>import pandas as pd
import numpy as np
import numba as nb

df = pd.DataFrame({"A" : np.random.rand(10)})
@nb.jit
def numba_mean(x):
    return np.sum(x) / len(x)

df.A.rolling(3).apply(numba_mean)
</code>```

However I get the below error, which means it does not work with nopython mode.

Compilation is falling back to object mode WITH looplifting enabled because Function "numba_mean" failed type inference due to: non-precise type pyobject

The Error traceback when applying numba_mean with njit rather than jit

This error may have been caused by the following argument(s):
  - argument 0: cannot determine Numba type of <class 'pandas.core.series.Series'>

I was wondering if there is a way to use the numbafied functions with a pandas rolling object ?

答:
You need to specify the engine keyword to let Pandas know you want to use Numba:

```<code>df.A.rolling(3).apply(numba_mean, engine='numba', raw=True)
</code>```

Pandas can jit the function for you, but I get faster results when I do it myself. Perhaps Numba is recompiling for every call to .apply() and the timings below include compilation time.

With such a simple function, and a small amount of data for each call (window=3), it's unlikely that you'll get any speedup over the built-in function.

```<code>import pandas as pd
import numpy as np
import numba as nb

@nb.njit(nogil=True)
def numba_mean(x):
    return np.sum(x) / x.size

def numpy_mean(x):
    return np.sum(x) / x.size

df = pd.DataFrame({"A" : np.random.rand(10000)})
</code>```

Body:
With the pandas 1.0.0 release, .apply now has the ability to use numba jit functions.

Is there a way to take advantage of this .apply functionality when using .rolling ?

For example I have a pandas.DataFrame, and a numba_mean function I would like to apply to get a rolling mean of 3 periods.

import pandas as pd
import numpy as np
import numba as nb

df = pd.DataFrame({"A" : np.random.rand(10)})
@nb.jit
def numba_mean(x):
    return np.sum(x) / len(x)

df.A.rolling(3).apply(numba_mean)

However I get the below error, which means it does not work with nopython mode.

Compilation is falling back to object mode WITH looplifting enabled because Function "numba_mean" failed type inference due to: non-precise type pyobject

The Error traceback when applying numba_mean with njit rather than jit

This error may have been caused by the following argument(s):
  - argument 0: cannot determine Numba type of <class 'pandas.core.series.Series'>

I was wondering if there is a way to use the numbafied functions with a pandas rolling object ?

Body:
You need to specify the engine keyword to let Pandas know you want to use Numba:

df.A.rolling(3).apply(numba_mean, engine='numba', raw=True)

Pandas can jit the function for you, but I get faster results when I do it myself. Perhaps Numba is recompiling for every call to .apply() and the timings below include compilation time.

With such a simple function, and a small amount of data for each call (window=3), it's unlikely that you'll get any speedup over the built-in function.

import pandas as pd
import numpy as np
import numba as nb

@nb.njit(nogil=True)
def numba_mean(x):
    return np.sum(x) / x.size

def numpy_mean(x):
    return np.sum(x) / x.size

df = pd.DataFrame({"A" : np.random.rand(10000)})


问:
Why does a CSS transition not work well with another animation based on jQuery's animate method?
I have a button that I wish to move when it is clicked, and while moving it should also flip. So there are two animations that take place at the same time, and have the same duration. I also have a CSS transition set up for all the properties of the button. It seems to me that only the CSS scale transform works when I use both jQuery's animate method and the CSS transition effect. When I remove one of the animations, the other one works well.

// find elements
var button = $("button");

// handle click
button.on("click", function() {
  button.css({
    "transform": "scaleX(0)"
  });

 // the bug: the following animation is not visible
  button.animate({
    "top": "-100px" // I tried without "px" too
  }, 0.15 * 1000);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 15px;
  color: #fff;

  position: relative;
  transition: all 0.15s;
}</code>```

Hello World

  <button>Click me</button>

```

The JSFiddle is here.

Thank you.

答:
Use only the required property in transition i.e. transform 0.15s instead of all 0.15s

// find elements
var button = $("button");

// handle click
button.on("click", function() {
  button.css({
    "transform": "scaleX(0)"
  });

  // the bug: the following animation is not visible
  button.animate({
    "top": "-100px" // I tried without "px" too
  }, 0.15 * 1000);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 15px;
  color: #fff;

  position: absolute;
  transition: transform 0.15s; /* change here*/
}</code>```

Hello World

  <button>Click me</button>

```

Body:
I have a button that I wish to move when it is clicked, and while moving it should also flip. So there are two animations that take place at the same time, and have the same duration. I also have a CSS transition set up for all the properties of the button. It seems to me that only the CSS scale transform works when I use both jQuery's animate method and the CSS transition effect. When I remove one of the animations, the other one works well.

// find elements
var button = $("button");

// handle click
button.on("click", function() {
  button.css({
    "transform": "scaleX(0)"
  });

 // the bug: the following animation is not visible
  button.animate({
    "top": "-100px" // I tried without "px" too
  }, 0.15 * 1000);
});

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 15px;
  color: #fff;

  position: relative;
  transition: all 0.15s;
}

Hello World

  <button>Click me</button>

The JSFiddle is here.

Thank you.

Body:
Use only the required property in transition i.e. transform 0.15s instead of all 0.15s

// find elements
var button = $("button");

// handle click
button.on("click", function() {
  button.css({
    "transform": "scaleX(0)"
  });

  // the bug: the following animation is not visible
  button.animate({
    "top": "-100px" // I tried without "px" too
  }, 0.15 * 1000);
});

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 15px;
  color: #fff;

  position: absolute;
  transition: transform 0.15s; /* change here*/
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
  <p>Hello World</p>
  <button>Click me</button>
</div>


问:
Why NetworkChange.NetworkAddressChanged Event fired twice?
When I turn off or turn on the network connection, the event is fired twice.
If network is down, the address is 127.0.0.1, but when the network is connected, the first event displays the same address (127.0.0.1 has not changed!), and the second displays the other address (required, for example 192.168.1.2)</p>

答:
The event NetworkChange.NetworkAddressChanged fire twice because the network interface which has its address changed has the IPv4 and IPv6 enabled.

If you disable the IPv4 or the IPv6 on the network interface like the picture I joined, the event will fire only one time.


问:
How to get all buttons at once?
```<code>Button button = findViewById(R.id.button1);
</code>```

That's the only way I know to get the button, but I have 45 buttons and it's too hard for me to get the buttons one by one.

Is there is any way to get all the buttons at once?

答:
If you have 45 buttons on the screen, I'm thinking maybe you need to use a RecyclerView, to display one button, and then duplicate it a lot of times.
Their click listener will depend on the button index.</p>

Title: How to get all buttons at once?

Body:
Button button = findViewById(R.id.button1);

That's the only way I know to get the button, but I have 45 buttons and it's too hard for me to get the buttons one by one.

Is there is any way to get all the buttons at once?


问:
How To Graph Points With Sympy?
I need to calculate and graph a function and it's first two derivatives. Then, I need to graph the minimum and maximum points of the original function on the graph. I have calculated these, but am lost as to how to graph the data.
The x values for the minimum/maximum points are
criticalPoints[]

with the y values being

criticalPointsY[]

Here is the segment of code where the error appears.

```<code>equation=CreateFunction();
    firstDeriv=equation.diff(x);
    secondDeriv=firstDeriv.diff(x);
    print(equation);
criticalPoints=solveset(firstDeriv,x);
criticalPointsY=[];
for a in criticalPoints:
    criticalPointsY.append(equation.subs(x,a));

p=plot(equation,firstDeriv,secondDeriv,(x,-10,10));
# Need to add the critical points to the graph. We have them, and the
# y values, but need to put them on the graphs.
print(criticalPoints)
print(criticalPointsY);
for a in range(0, len(criticalPoints)):
    xval=criticalPoints[a];
    yval=criticalPointsY[a];
    plt.plot(xval, yval, 'ro')
p.show();
plt.show();
</code>```

When I run the program, I get this error.
`

```<code>Traceback (most recent call last):
  File "--------", line 58, in <module>
    xval=criticalPoints[a];
TypeError: 'FiniteSet' object does not support indexing
</code>```

I have tried plotting the points on p and get a different error

```<code>    p.plot(criticalPoints,criticalPointsY);
AttributeError: 'Plot' object has no attribute 'plot'
</code>```

Is there a way to plot points on this graph? (p)

答:
In order to use Sympy to define critical points in this case, and to plot the results in matplotlib.pyplot, the sympy.utilities.lambdify method can be used to generate lists of points to graph in mathplotlib (Following post by user6655984).

Arrays are constructed, but may not have the same length if a constant value is plotted which is problematic in a  numpy.transpose step. Hence, a condition is passed before the first matplotlib.pyplot.

```<code>from sympy import *
import numpy as np
import matplotlib.pyplot as plt

x = symbols('x')
equation = x**2 + 2 #OK = x*exp(-x**2/10) OR x**2 + 2
firstDeriv = equation.diff(x)
secondDeriv = firstDeriv.diff(x)
criticalPoints = list(solveset(firstDeriv, x))
criticalPointsY = [equation.subs(x, a) for a in criticalPoints]
xx = np.linspace(-10, 10, 100)
lam_f= lambdify(x, [equation, firstDeriv, secondDeriv])
yy=[elem if  type(elem) == np.ndarray else np.full(len(xx), elem) for elem in lam_f(xx)]
plt.plot(xx, np.transpose(yy))
plt.plot(criticalPoints, criticalPointsY, 'k*')
plt.show()
</code>```

Title: How To Graph Points With Sympy?

Body:
I need to calculate and graph a function and it's first two derivatives. Then, I need to graph the minimum and maximum points of the original function on the graph. I have calculated these, but am lost as to how to graph the data.
The x values for the minimum/maximum points are
criticalPoints[]

with the y values being

criticalPointsY[]

Here is the segment of code where the error appears.

equation=CreateFunction();
    firstDeriv=equation.diff(x);
    secondDeriv=firstDeriv.diff(x);
    print(equation);
criticalPoints=solveset(firstDeriv,x);
criticalPointsY=[];
for a in criticalPoints:
    criticalPointsY.append(equation.subs(x,a));

p=plot(equation,firstDeriv,secondDeriv,(x,-10,10));
# Need to add the critical points to the graph. We have them, and the
# y values, but need to put them on the graphs.
print(criticalPoints)
print(criticalPointsY);
for a in range(0, len(criticalPoints)):
    xval=criticalPoints[a];
    yval=criticalPointsY[a];
    plt.plot(xval, yval, 'ro')
p.show();
plt.show();

When I run the program, I get this error.
`

Traceback (most recent call last):
  File "--------", line 58, in <module>
    xval=criticalPoints[a];
TypeError: 'FiniteSet' object does not support indexing

I have tried plotting the points on p and get a different error

    p.plot(criticalPoints,criticalPointsY);
AttributeError: 'Plot' object has no attribute 'plot'

Is there a way to plot points on this graph? (p)

Body:
In order to use Sympy to define critical points in this case, and to plot the results in matplotlib.pyplot, the sympy.utilities.lambdify method can be used to generate lists of points to graph in mathplotlib (Following post by user6655984).

Arrays are constructed, but may not have the same length if a constant value is plotted which is problematic in a  numpy.transpose step. Hence, a condition is passed before the first matplotlib.pyplot.

from sympy import *
import numpy as np
import matplotlib.pyplot as plt

x = symbols('x')
equation = x**2 + 2 #OK = x*exp(-x**2/10) OR x**2 + 2
firstDeriv = equation.diff(x)
secondDeriv = firstDeriv.diff(x)
criticalPoints = list(solveset(firstDeriv, x))
criticalPointsY = [equation.subs(x, a) for a in criticalPoints]
xx = np.linspace(-10, 10, 100)
lam_f= lambdify(x, [equation, firstDeriv, secondDeriv])
yy=[elem if  type(elem) == np.ndarray else np.full(len(xx), elem) for elem in lam_f(xx)]
plt.plot(xx, np.transpose(yy))
plt.plot(criticalPoints, criticalPointsY, 'k*')
plt.show()


问:
How to handle pop up window dialog to download file automatically with firefox profile in python selenium on Linux (Ubuntu) system
I am trying to download the file automatically from system file download dialog by setting preference in firefox  profile in my python selenium code , but my code is not working.

Browser : Firefox 72.0
Selenium Version : 3.14
OS : linux Ubuntu
Filetype to download: *.enc (encrypted file type)
Path of firefox in linux : /usr/bin/firefox

Code :

```<code>profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", "/home/user/Downloads/tests")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-uuencoded,application/octet-stream")
self.driver = webdriver.Firefox(firefox_profile=profile)
</code>```

答:
I have the same problem with Firefox 72.0, but with pdf files. This is the code:

```<code>fp = webdriver.FirefoxProfile()
fp.set_preference("pdfjs.disabled", True)
fp.set_preference("browser.download.folderList", 2)
fp.set_preference("browser.download.dir", "/path")
fp.set_preference("browser.download.downloadDir", "/path")
fp.set_preference("browser.download.defaultFolder", "/path")
fp.set_preference("plugin.disable_full_page_plugin_for_types", "application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf, application/vnd.cups-pdf")
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf, application/vnd.cups-pdf")
fp.set_preference("browser.helperApps.neverAsk.openFile", "application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf, application/vnd.cups-pdf")

driver = webdriver.Firefox(firefox_profile=fp)
</code>```

I have tried all possible preferences, but it always triggers the download alert.

Body:
I am trying to download the file automatically from system file download dialog by setting preference in firefox  profile in my python selenium code , but my code is not working.

Browser : Firefox 72.0
Selenium Version : 3.14
OS : linux Ubuntu
Filetype to download: *.enc (encrypted file type)
Path of firefox in linux : /usr/bin/firefox

Code :

profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", "/home/user/Downloads/tests")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-uuencoded,application/octet-stream")
self.driver = webdriver.Firefox(firefox_profile=profile)

Body:
I have the same problem with Firefox 72.0, but with pdf files. This is the code:

fp = webdriver.FirefoxProfile()
fp.set_preference("pdfjs.disabled", True)
fp.set_preference("browser.download.folderList", 2)
fp.set_preference("browser.download.dir", "/path")
fp.set_preference("browser.download.downloadDir", "/path")
fp.set_preference("browser.download.defaultFolder", "/path")
fp.set_preference("plugin.disable_full_page_plugin_for_types", "application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf, application/vnd.cups-pdf")
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf, application/vnd.cups-pdf")
fp.set_preference("browser.helperApps.neverAsk.openFile", "application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf, application/vnd.cups-pdf")

driver = webdriver.Firefox(firefox_profile=fp)

I have tried all possible preferences, but it always triggers the download alert.


问:
How do you detach and re-attach items with different classes on different lists using jQuery?
I am working on a page with a dropdown selector and three separate lists, where selecting an option on the dropdown would do a detach() on all the items on each list except for those with a class name the corresponds with the value="" of the option currently selected, without affecting their nth-child styles. (E.g. selecting "green" on the dropdown would result in each list only showing li elements with class "item-green" appearing.)

Currently, when an option on the dropdown is selected the first time, everything works as expected. However, when the selected option changes on all succeeding tries, nothing on each list appears.

var detach;

$("select").change(function() {
  var current = $("select option:selected").attr("value");
  var currentClass = ".item-" + current;

  $('.lists').show(0);

  $('.lists ul').each(function() {
    var detach = $(this).find("li").detach();
    var detachFiltered = detach.filter(currentClass);
    $(this).append(detachFiltered);
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.lists {
  display: none;
}</code>```

<select>
  <option selected disabled>Choose a color:</option>
  <option value="red">Red</option>
  <option value="green">Green</option>
  <option value="blue">Blue</option>
</select>

Set 1

Burgundy

Chartreuse

Cyan

Set 2

Crimson

Olive

Cyan

Set 3

Scarlet

Lime

Ultramarine

```

答:
Instead of detaching/reattaching the li in the DOM your code can be made much more simple by just toggling a class on the relevant elements to display/hide them.

Note in the example below that I amended the classes on the li to have a common .item to make targeting them easier, and a separate class to determine the colour they belong to. Try this:

$("select").change(function() {
  var current = $(this).val();
  $('.lists').show().find('.item').removeClass('active').filter('.' + current).addClass('active');
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.lists { display: none; }
.item { display: none; }
.item.active { display: block; }</code>```

<select>
  <option selected disabled>Choose a color:</option>
  <option value="red">Red</option>
  <option value="green">Green</option>
  <option value="blue">Blue</option>
</select>

Set 1

Burgundy

Chartreuse

Cyan

Set 2

Crimson

Olive

Cyan

Set 3

Scarlet

Lime

Ultramarine

```

Body:
I am working on a page with a dropdown selector and three separate lists, where selecting an option on the dropdown would do a detach() on all the items on each list except for those with a class name the corresponds with the value="" of the option currently selected, without affecting their nth-child styles. (E.g. selecting "green" on the dropdown would result in each list only showing li elements with class "item-green" appearing.)

Currently, when an option on the dropdown is selected the first time, everything works as expected. However, when the selected option changes on all succeeding tries, nothing on each list appears.

var detach;

$("select").change(function() {
  var current = $("select option:selected").attr("value");
  var currentClass = ".item-" + current;

  $('.lists').show(0);

  $('.lists ul').each(function() {
    var detach = $(this).find("li").detach();
    var detachFiltered = detach.filter(currentClass);
    $(this).append(detachFiltered);
  });
});

.lists {
  display: none;
}

<select>
  <option selected disabled>Choose a color:</option>
  <option value="red">Red</option>
  <option value="green">Green</option>
  <option value="blue">Blue</option>
</select>

Set 1

Burgundy

Chartreuse

Cyan

Set 2

Crimson

Olive

Cyan

Set 3

Scarlet

Lime

Ultramarine

Body:
Instead of detaching/reattaching the li in the DOM your code can be made much more simple by just toggling a class on the relevant elements to display/hide them.

Note in the example below that I amended the classes on the li to have a common .item to make targeting them easier, and a separate class to determine the colour they belong to. Try this:

$("select").change(function() {
  var current = $(this).val();
  $('.lists').show().find('.item').removeClass('active').filter('.' + current).addClass('active');
});

.lists { display: none; }
.item { display: none; }
.item.active { display: block; }

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<select>
  <option selected disabled>Choose a color:</option>
  <option value="red">Red</option>
  <option value="green">Green</option>
  <option value="blue">Blue</option>
</select>
<div class="lists">
  <section>
    <h1>Set 1</h1>
    <ul>
      <li class="item red">Burgundy</li>
      <li class="item green">Chartreuse</li>
      <li class="item blue">Cyan</li>
    </ul>
  </section>
  <section>
    <h1>Set 2</h1>
    <ul>
      <li class="item red">Crimson</li>
      <li class="item green">Olive</li>
      <li class="item blue">Cyan</li>
    </ul>
  </section>
  <section>
    <h1>Set 3</h1>
    <ul>
      <li class="item red">Scarlet</li>
      <li class="item green">Lime</li>
      <li class="item blue">Ultramarine</li>
    </ul>
  </section>
</div>


问:
Why does my for loop sometimes execute twice, despite my use of a break statement?
In the code below, the first if-statement inside the for loop sometimes fires twice. It logs "hello" twice, and the same SMS is send twice, despite of the break-statement. What's wierd is that it only happens about 30% of the time. Any help is appreciated.</p>

```<code>for (let indexS = prisData.length - 1; -1 < indexS; indexS--) {
        if (prisData[indexS].købt === true && prisData[indexS].købtFor < købsPrisNu - netto) {
            solgtFor = købsPrisNu
            solgt = true
            console.log("hello");
            nexmo.message.sendSms(from, to, 'Sælg wirtek til ' + solgtFor, {type : 'text'},(err, data) => {if (err != null) {console.log(err)}})
            break
        }
        if (prisData[indexS].solgt === true) {
            break
        }
    }
</code>```

答:
Let me simplify this code for you:

```<code>function foo()
{
    for ([...]) {
            if (...) {
                [...]
                console.log("hello");
                sendSms();
                break
            }
              [...]
        }
}
</code>```

Regardless of what is in the [...] parts, the console.log("hello") statement cannot be called twice for one call of foo().

The only reasonable possibility for the log statement being executed more than once is if the function is called multiple times or if it calls itself (e.g. sendSms() calls foo() directly or indirectly).

Body:
In the code below, the first if-statement inside the for loop sometimes fires twice. It logs "hello" twice, and the same SMS is send twice, despite of the break-statement. What's wierd is that it only happens about 30% of the time. Any help is appreciated.

for (let indexS = prisData.length - 1; -1 < indexS; indexS--) {
        if (prisData[indexS].købt === true && prisData[indexS].købtFor < købsPrisNu - netto) {
            solgtFor = købsPrisNu
            solgt = true
            console.log("hello");
            nexmo.message.sendSms(from, to, 'Sælg wirtek til ' + solgtFor, {type : 'text'},(err, data) => {if (err != null) {console.log(err)}})
            break
        }
        if (prisData[indexS].solgt === true) {
            break
        }
    }

Body:
Let me simplify this code for you:

function foo()
{
    for ([...]) {
            if (...) {
                [...]
                console.log("hello");
                sendSms();
                break
            }
              [...]
        }
}

Regardless of what is in the [...] parts, the console.log("hello") statement cannot be called twice for one call of foo().

The only reasonable possibility for the log statement being executed more than once is if the function is called multiple times or if it calls itself (e.g. sendSms() calls foo() directly or indirectly).


问:
How could i send notfication app to web in node js i am new to nodejs please if you can
i have to send a notification on  web when a event occurs on app  </p>

答: Assuming you are using ReactJS, you need to use WebSockets. Check this tutorial on how to achieve that.</p>


问:
C Segmentation Fault While using scanf for 2D array
As suggested by a book of "Gottfried", I tried to input an array and display the contents of array in matrix form :

```<code>#include<stdio.h>

#define row 2
#define col 3

int main(){
    int (*a)[col];
    int i,j;

    for(i=0;i<row;i++){
        for(j=0;i<col;j++){
            printf("Enter a(%d,%d)",i,j);
            scanf("%d",(*(a+i)+j));
        }
    }

    return 0;
}
</code>```

I get the following output after inputting an element :

Segmentation fault (core dumped)

What is the problem in the code? Was it working in previous version of GCC so the writer wrote it down? What is the correct way to solve the problem with the same level of simplicity?

答:
If you want to declare a as a pointer to an array of col ints, as it's done in this line

```<code>int (*a)[col];
</code>```

Then you should also allocate (and ultimately free) the memory needed, before trying to use it.

```<code>a = malloc(sizeof(*a) * row);
if (!a)
    exit(1);
// ...
free(a);
</code>```

The posted code also have another issue in the nested loops

```<code>for (i = 0; i < row; i++) {
    for (j = 0; i < col; j++) {
//              ^^^^^^^           It should be 'j < col'
</code>```

Body:
As suggested by a book of "Gottfried", I tried to input an array and display the contents of array in matrix form :

#include<stdio.h>

#define row 2
#define col 3

int main(){
    int (*a)[col];
    int i,j;

    for(i=0;i<row;i++){
        for(j=0;i<col;j++){
            printf("Enter a(%d,%d)",i,j);
            scanf("%d",(*(a+i)+j));
        }
    }

    return 0;
}

I get the following output after inputting an element :

Segmentation fault (core dumped)

What is the problem in the code? Was it working in previous version of GCC so the writer wrote it down? What is the correct way to solve the problem with the same level of simplicity?

Body:
If you want to declare a as a pointer to an array of col ints, as it's done in this line

int (*a)[col];

Then you should also allocate (and ultimately free) the memory needed, before trying to use it.

a = malloc(sizeof(*a) * row);
if (!a)
    exit(1);
// ...
free(a);

The posted code also have another issue in the nested loops

for (i = 0; i < row; i++) {
    for (j = 0; i < col; j++) {
//              ^^^^^^^           It should be 'j < col'


问:
Substring datafame string column
I have a dataframe with one column:

```<code>x = data.frame(col = c('PS-01','PS-02','PS-03','PS-04','PS-05','PS-06')

  )

</code>```

I want to substring it with stringr and get new dataframe with int after PS- which lookslike this:

```<code>x_new = data.frame(col = c(01,02,03,04,05,06)
</code>```

How could i do that?

答:
We can use stringr's str_extract

```<code>stringr::str_extract(x$col, "(?<=PS-)\\d+")
#[1] "01" "02" "03" "04" "05" "06"
</code>```

Or using the same pattern in base R :

```<code>unlist(regmatches(x$col, gregexpr("(?<=PS-)\\d+", x$col, perl = TRUE)))
</code>```

Title: Substring datafame string column

Body:
I have a dataframe with one column:

x = data.frame(col = c('PS-01','PS-02','PS-03','PS-04','PS-05','PS-06')

  )

I want to substring it with stringr and get new dataframe with int after PS- which lookslike this:

x_new = data.frame(col = c(01,02,03,04,05,06)

How could i do that?

Body:
We can use stringr's str_extract

stringr::str_extract(x$col, "(?<=PS-)\\d+")
#[1] "01" "02" "03" "04" "05" "06"

Or using the same pattern in base R :

unlist(regmatches(x$col, gregexpr("(?<=PS-)\\d+", x$col, perl = TRUE)))


问:
php + mysql query returning only a single row (std class) from class function
Can you tell me why this returns only the last row of my query?
As you see I'm extracting as std class. Also I already tried different approaches like a foreach key=>value inside the while but it does not help. I can't populate $out correctly.</p>

```<code>class myclass {

    function Query($sql){

    $results = $this->db->query($sql);

    if (mysqli_num_rows($results)<1){
        throw new Exception('NoResults');
    }

    $out = new stdClass;
    while ($r = $results->fetch_object()){

        $out = $r;
    }

    return $out;
    $out = null;
    }

}

}

---------------

$client = new myclass;

    $sql = "SELECT * FROM books";
    $q = $client->Query($sql);

    print_r($q);
</code>```

答:
You are overwriting $out at every iteration of the while, so you'll have only the last result in the return. You could use an array and append the results (it could be an array of stdClass objects), and then you'll be able to work with it with a simple loop

```<code>class myclass {

    function Query($sql){

        $results = $this->db->query($sql);

        if (mysqli_num_rows($results)<1){
            throw new Exception('NoResults');
        }

        //copied this piece of code from @Berto99 answer from this same question
        $out = []; // array that will hold all the objects
        while ($r = $results->fetch_object()){
            array_push($out, $r);  // add to the array the current object
        }
        return $out; //return the array with the objects
    }

}

---------------

$client = new myclass;

$sql = "SELECT * FROM books";
$q = $client->Query($sql);

foreach($q as $resultLine){
    //do whatever you need to do here
}
</code>```

Body:
Can you tell me why this returns only the last row of my query?
As you see I'm extracting as std class. Also I already tried different approaches like a foreach key=>value inside the while but it does not help. I can't populate $out correctly.

class myclass {

    function Query($sql){

    $results = $this->db->query($sql);

    if (mysqli_num_rows($results)<1){
        throw new Exception('NoResults');
    }

    $out = new stdClass;
    while ($r = $results->fetch_object()){

        $out = $r;
    }

    return $out;
    $out = null;
    }

}

}

---------------

$client = new myclass;

    $sql = "SELECT * FROM books";
    $q = $client->Query($sql);

    print_r($q);

Body:
You are overwriting $out at every iteration of the while, so you'll have only the last result in the return. You could use an array and append the results (it could be an array of stdClass objects), and then you'll be able to work with it with a simple loop

class myclass {

    function Query($sql){

        $results = $this->db->query($sql);

        if (mysqli_num_rows($results)<1){
            throw new Exception('NoResults');
        }

        //copied this piece of code from @Berto99 answer from this same question
        $out = []; // array that will hold all the objects
        while ($r = $results->fetch_object()){
            array_push($out, $r);  // add to the array the current object
        }
        return $out; //return the array with the objects
    }

}

---------------

$client = new myclass;

$sql = "SELECT * FROM books";
$q = $client->Query($sql);

foreach($q as $resultLine){
    //do whatever you need to do here
}


问:
@vue-composition / How can I use asynchronous methods in setup()
```<code><script lang="ts">
import { createComponent } from "@vue/composition-api";

import { SplashPage } from "../../lib/vue-viewmodels";

export default createComponent({
  async setup(props, context) {
    await SplashPage.init(2000, context.root.$router, "plan", "login");
  }
});
</script>
</code>```

ERROR: "setup" must return a "Object" or a "Function", got "Promise"

答:
The setup function <s>must be synchronous</s> can be async using Suspense.

How to avoid using async setup (obsolete answer)

An onMounted hook can be used with an async callback:

```<code>import { onMounted } from "@vue/composition-api";

// …
export default createComponent({
  setup(props, context) {
    onMounted(async () => {
      await SplashPage.init(2000, context.root.$router, "plan", "login");
    )};
  }
});
</code>```

Or, it is always possible to call an asynchronous function without to await it:

```<code>SplashPage.init(2000, context.root.$router, "plan", "login")
  .catch(console.log);
</code>```

In both cases, you'll have to take into account that the component will be rendered before the execution of the asynchronous function. A simple way to not display something that would depends on it is to use v-if in your template.

Body:
The setup function <s>must be synchronous</s> can be async using Suspense.

How to avoid using async setup (obsolete answer)

An onMounted hook can be used with an async callback:

import { onMounted } from "@vue/composition-api";

// …
export default createComponent({
  setup(props, context) {
    onMounted(async () => {
      await SplashPage.init(2000, context.root.$router, "plan", "login");
    )};
  }
});

Or, it is always possible to call an asynchronous function without to await it:

SplashPage.init(2000, context.root.$router, "plan", "login")
  .catch(console.log);

In both cases, you'll have to take into account that the component will be rendered before the execution of the asynchronous function. A simple way to not display something that would depends on it is to use v-if in your template.


问:
how to check BLE Gatt Client Mode is supported by device?
In android, I have used BLE both mode as Peripheral and Client. But I want to check isBLeGattClientSupported()

As we know some devices in android are not capable to act as BLE Gatt Client so jut wants to throw an exception that such device is not able to act as client.

I have the rest of the past for BLE my code is working fine for both mode, but stuck when I said to my device to act as a client and that device is not capable to act as the client.

答: All android devices that have a bluetooth chip (4.0 and above) running Android 4.3 above supports BLE and all these devices supports acting as a BluetoothGatt client as well as a BluetoothGattServer as mentioned in the documentation.</p>