I wish other languages did what Nim does. Take dart for example:
    
    
    class _SunflowerState extends State<Sunflower> {
      double seeds = 100.0;
      
      int get seedCount => seeds.floor();
      
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData().copyWith(
            platform: platform,
            brightness: Brightness.dark,
            sliderTheme: SliderThemeData.fromPrimaryColors(
              primaryColor: primaryColor,
              primaryColorLight: primaryColor,
              primaryColorDark: primaryColor,
              valueIndicatorTextStyle: const DefaultTextStyle.fallback().style,
            ),
          ),
          home: Scaffold(
            appBar: AppBar(
              title: const Text("Sunflower"),
            ),
            drawer: Drawer(
              child: ListView(
                children: const [
                  DrawerHeader(
                    child: Center(
                      child: Text(
                        "Sunflower 🌻",
                        style: TextStyle(fontSize: 32),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            body: Container(
              constraints: const BoxConstraints.expand(),
              decoration: BoxDecoration(
                border: Border.all(
                  color: Colors.transparent,
                ),
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  Container(
                    decoration: BoxDecoration(
                      border: Border.all(
                        color: Colors.transparent,
                      ),
                    ),
                    child: SizedBox(
                      width: 400,
                      height: 400,
                      child: CustomPaint(
                        painter: SunflowerPainter(seedCount),
                      ),
                    ),
                  ),
                  Text("Showing $seedCount seeds"),
                  ConstrainedBox(
                    constraints: const BoxConstraints.tightFor(width: 300),
                    child: Slider.adaptive(
                      min: 20,
                      max: 2000,
                      value: seeds,
                      onChanged: (newValue) {
                        setState(() {
                          seeds = newValue;
                        });
                      },
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }
    
    
    Run

The above would for me be more readable without:
    
    
                      },
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }
    
    
    Run

Reply via email to