APIs that delight me« an older post

Dart / Flutter things


(not so dumpy) Dump of things that I've needed to look up recently for Dart / Flutter work

// Use assert to display messages when running in debug mode, as assert runs only when in Debug mode
// https://stackoverflow.com/questions/49707028/check-if-running-app-is-in-debug-mode
// note the () at the end, and return a boolean
assert(() {
  if (something == null || somethingElse == null) {
    throw new FlutterError(
      'Something or other went wrong\n'
      'And should probably be fixed.'
  return true;
// setting the colors of a bottom navigation bar
// https://stackoverflow.com/questions/49927929/flutter-bottomnavigationbar-colors
bottomNavigationBar: new BottomNavigationBar(
  // this is the needed part to control the colors
  type: BottomNavigationBarType.fixed, 
  // this is the icon color, defaults to the  ThemeData.primaryColor 
  fixedColor: Colors.orange,
  items: [
    new BottomNavigationBarItem(
        icon: new Icon(Icons.home),
        title: new Text("home")

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.