Image

flutter

Notes

Notes about Flutter

1 min read
Last update: November 28, 2021

// Concat variable into String

'$_api/real-estate-companies'

// stringify JSON

print(json.decode(response.body));

// Extract first result from List

List<Currency> currencies = ...;
Currency dollar = currencies.firstWhere((currency) => currency.code == "USD");

// Passing Data to a Stateful Widget

class ServerIpText extends StatefulWidget {
  final String serverIP;

  const ServerIpText ({ Key key, this.serverIP }): super(key: key);

  
  _ServerIpTextState createState() =>_ServerIpTextState();
}

class _ServerIpTextState extends State<ServerIpText> {
  
  Widget build(BuildContext context) {
    return Text(widget.serverIP);
  }
}

class AnotherClass extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return Center(
      child: ServerIpText(serverIP: "127.0.0.1")
    );
  }
}

// Factory, if exist

https://stackoverflow.com/questions/58141074/how-do-i-import-a-json-property-to-a-dart-object-when-it-may-or-may-not-exist

// Built split by abi

flutter build apk --split-per-abi

// Stringify List

https://stackoverflow.com/questions/59143173/convert-list-to-json-string-then-convert-this-string-back-to-list-in-dart