code_box 1.3.0 copy "code_box: ^1.3.0" to clipboard
code_box: ^1.3.0 copied to clipboard

Helpful extensions for your daily work making your code more readable.

Code Box #

Code Box is a growing collection of useful code snippets for flutter and/or dart. Feel free to contribute by yourself.

Current Features #

List #

flatMap #

import 'package:code_box/code_box.dart';

/// for example youve got a column with conditional build
Widget build(BuildContext context) {
    return Column(
        children: [
            (text != null) ? Text("test") : null,
            Text("next Line"),
            (secondText != null) ? Text("second Text") : null
        ] /// usually you would be told that
        /// you cant build the children like that because null is not a type of widget
        /// with flat map you can call
        .flatMap() /// the magic happens and the conditional build starts :)   
    );
}

unique #

    final list = ["test", "test", "test1", "test2", "test4", "test1", "test2"];
    final List<String> uniqued = list.unique(); /// magic happens and the list is uniqued by its type

Widget Modifier #

padding & scrollbar & safearea #

basic features holding the normal initializer from those base widgets.

Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
            children: [
                Text("test"),
                Text("test2")
            ]
        ).padding(left: 15, right: 15, bottom: 5)
        .safeArea()
        // personal opinion but long build blocs with paddings get more readable
        // same usage with safe area and scrollbar
    );
}
3
likes
140
pub points
32%
popularity

Publisher

verified publisheramazdev.de

Helpful extensions for your daily work making your code more readable.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on code_box