dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.59k forks source link

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

Open dvorapa opened 5 years ago

dvorapa commented 5 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