dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
634 stars 170 forks source link

Consider not throwing prefer_expression_function_bodies if returning multiline declaration of Widget inside #1850

Open dvorapa opened 4 years ago

dvorapa commented 4 years ago

Describe the issue If there is a large multiline declaration of some Widget returned inside, the code seems to be more clean with curly braces.

To Reproduce

                              Builder(builder: (BuildContext context) {
                                return Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    Row(
                                      children: <Widget>[
                                        Tooltip(
                                          message: 'Select start',
                                          child: InkWell(
                                              onTap: () {},
                                              child: Padding(
                                                padding: EdgeInsets.symmetric(
                                                    horizontal: 20.0,
                                                    vertical: 16.0),
                                                child: Text('A',
                                                    style: TextStyle(
                                                        fontSize: 15.0,
                                                        fontWeight:
                                                            FontWeight.bold,
                                                        color:
                                                            backgroundColor)),
                                              )),
                                        ),
                                        Tooltip(
                                          message: 'Select end',
                                          child: InkWell(
                                              onTap: () {},
                                              child: Padding(
                                                padding: EdgeInsets.symmetric(
                                                    horizontal: 20.0,
                                                    vertical: 16.0),
                                                child: Text('B',
                                                    style: TextStyle(
                                                        fontSize: 15.0,
                                                        fontWeight:
                                                            FontWeight.bold,
                                                        color:
                                                            backgroundColor)),
                                              )),
                                        ),
                                        IconButton(
                                          onPressed: () {
                                            onSet(context);
                                          },
                                          tooltip:
                                              'Set (one, all, or random songs)',
                                          icon: Icon(_status(_set), size: 20.0),
                                        ),
                                      ],
                                    ),
                                    Row(
                                      children: <Widget>[
                                        IconButton(
                                          onPressed: () {
                                            onMode(context);
                                          },
                                          tooltip: 'Mode (once or in a loop)',
                                          icon: Icon(
                                              _mode == 'loop'
                                                  ? Icons.repeat
                                                  : Icons.trending_flat,
                                              size: 20.0),
                                        ),
                                      ],
                                    ),
                                  ],
                                );
                              }),

vs

                            Builder(builder: (BuildContext context) =>
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    Row(
                                      children: <Widget>[
                                        Tooltip(
                                          message: 'Select start',
                                          child: InkWell(
                                              onTap: () {},
                                              child: Padding(
                                                padding: EdgeInsets.symmetric(
                                                    horizontal: 20.0,
                                                    vertical: 16.0),
                                                child: Text('A',
                                                    style: TextStyle(
                                                        fontSize: 15.0,
                                                        fontWeight:
                                                            FontWeight.bold,
                                                        color:
                                                            backgroundColor)),
                                              )),
                                        ),
                                        Tooltip(
                                          message: 'Select end',
                                          child: InkWell(
                                              onTap: () {},
                                              child: Padding(
                                                padding: EdgeInsets.symmetric(
                                                    horizontal: 20.0,
                                                    vertical: 16.0),
                                                child: Text('B',
                                                    style: TextStyle(
                                                        fontSize: 15.0,
                                                        fontWeight:
                                                            FontWeight.bold,
                                                        color:
                                                            backgroundColor)),
                                              )),
                                        ),
                                        IconButton(
                                          onPressed: () {
                                            onSet(context);
                                          },
                                          tooltip:
                                              'Set (one, all, or random songs)',
                                          icon: Icon(_status(_set), size: 20.0),
                                        ),
                                      ],
                                    ),
                                    Row(
                                      children: <Widget>[
                                        IconButton(
                                          onPressed: () {
                                            onMode(context);
                                          },
                                          tooltip: 'Mode (once or in a loop)',
                                          icon: Icon(
                                              _mode == 'loop'
                                                  ? Icons.repeat
                                                  : Icons.trending_flat,
                                              size: 20.0),
                                        ),
                                      ],
                                    ),
                                  ],
                                );
                              ),

Expected behavior This warning could be omited in this particular case.

Additional context Latest stable Flutter v1.9.1+h6 with Dart 2.5.0

FMorschel commented 2 years ago

Maybe consider letting some Configurable linters as DCM rules. Adding ignored-named-arguments like prefer-extracting-callbacks