kandi background
kandi background
Explore Kits
kandi background
Explore Kits
kandi background
Explore Kits
kandi background
Explore Kits
Explore all Widget open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Widget

fullPage.js 4.0.6

v1.15.0

v16.0.0

fullPage.js

fullPage.js 4.0.6

react-beautiful-dnd

Sortable

v1.15.0

react-dnd

v16.0.0

Vue.Draggable

Popular Libraries in Widget

Trending New libraries in Widget

Top Authors in Widget

1

9 Libraries

87

2

8 Libraries

57

3

8 Libraries

141

4

7 Libraries

471

5

6 Libraries

63780

6

6 Libraries

42

7

6 Libraries

133

8

6 Libraries

22

9

5 Libraries

76

10

5 Libraries

28

1

9 Libraries

87

2

8 Libraries

57

3

8 Libraries

141

4

7 Libraries

471

5

6 Libraries

63780

6

6 Libraries

42

7

6 Libraries

133

8

6 Libraries

22

9

5 Libraries

76

10

5 Libraries

28

Trending Kits in Widget

No Trending Kits are available at this moment for Widget

Trending Discussions on Widget

    Why does changing the background color of the navigation bar in Cupertino App change the height?
    "primaryColor" property in "ThemeData" does not work in Flutter
    Horizontal listview not scrolling on web but scrolling on mobile
    error with PhotoView : Looking up a deactivated widget's ancestor is unsafe
    Error: The non-abstract class 'InternalSelectableMathState'
    Why am I getting Backend Internal error: "Exception during IR lowering error" when using Jetpack Compose clickable-Modifier?
    Flutter Web: Cannot scroll with mouse down (drag) (Flutter 2.5+)
    Flutter resizeToAvoidBottomInset true not working with Expanded ListView
    Getting android.app.ForegroundServiceStartNotAllowedException in Android 12 (SDK 31)
    Move an item from one list to another with animation in Flutter

QUESTION

Why does changing the background color of the navigation bar in Cupertino App change the height?

Asked 2022-Mar-16 at 13:19

I have a widget demonstrating the rendering of a Flutter app. As it's written below, the text is visible right underneath the navigationBar. However, if you comment out the backgroundColor, it becomes invisible. Why is that?

1import 'package:flutter/cupertino.dart';
2import 'package:flutter/material.dart';
3
4void main() {
5  runApp(const MyApp());
6}
7
8class MyApp extends StatelessWidget {
9  const MyApp({Key? key}) : super(key: key);
10
11  @override
12  Widget build(BuildContext context) {
13    return CupertinoApp(
14      home: CupertinoPageScaffold(
15        navigationBar: const CupertinoNavigationBar(
16          middle: Text("Settings"),
17          previousPageTitle: "Back",
18          backgroundColor: Colors.blue,
19        ),
20        child: Column(
21          children: const <Widget>[
22            Text("Hello World!"),
23          ],
24        ),
25      ),
26    );
27  }
28}
29
30

Without blue color: Image without blue color

With blue color: Image with blue color

ANSWER

Answered 2022-Mar-16 at 13:19

The height is not changing with the backgroundColor, here's what CupertinoPageScaffold's documentation says:

Content can slide under the navigationBar when they're translucent. In that case, the child's BuildContext's MediaQuery will have a top padding indicating the area of obstructing overlap from the navigationBar.

This is why your text is hidden, it's simply going under the bar when its color is translucent. By using Colors.blue you will have an opaque color.

You can try by using backgroundColor: Colors.transparent the result will be the same as putting no color.

To fix this behavior you can wrap your Column with a SafeArea widget:

copy icondownload icon

1import 'package:flutter/cupertino.dart';
2import 'package:flutter/material.dart';
3
4void main() {
5  runApp(const MyApp());
6}
7
8class MyApp extends StatelessWidget {
9  const MyApp({Key? key}) : super(key: key);
10
11  @override
12  Widget build(BuildContext context) {
13    return CupertinoApp(
14      home: CupertinoPageScaffold(
15        navigationBar: const CupertinoNavigationBar(
16          middle: Text("Settings"),
17          previousPageTitle: "Back",
18          backgroundColor: Colors.blue,
19        ),
20        child: Column(
21          children: const <Widget>[
22            Text("Hello World!"),
23          ],
24        ),
25      ),
26    );
27  }
28}
29
30class MyApp extends StatelessWidget {
31  const MyApp({Key? key}) : super(key: key);
32
33  @override
34  Widget build(BuildContext context) {
35    return CupertinoApp(
36      home: CupertinoPageScaffold(
37        navigationBar: const CupertinoNavigationBar(
38          middle: Text("Settings"),
39          previousPageTitle: "Back",
40        ),
41        child: SafeArea(
42          child: Column(
43            children: const <Widget>[
44              Text("Hello World!"),
45            ],
46          ),
47        ),
48      ),
49    );
50  }
51}
52

Source https://stackoverflow.com/questions/71490932

Community Discussions contain sources that include Stack Exchange Network

    Why does changing the background color of the navigation bar in Cupertino App change the height?
    "primaryColor" property in "ThemeData" does not work in Flutter
    Horizontal listview not scrolling on web but scrolling on mobile
    error with PhotoView : Looking up a deactivated widget's ancestor is unsafe
    Error: The non-abstract class 'InternalSelectableMathState'
    Why am I getting Backend Internal error: "Exception during IR lowering error" when using Jetpack Compose clickable-Modifier?
    Flutter Web: Cannot scroll with mouse down (drag) (Flutter 2.5+)
    Flutter resizeToAvoidBottomInset true not working with Expanded ListView
    Getting android.app.ForegroundServiceStartNotAllowedException in Android 12 (SDK 31)
    Move an item from one list to another with animation in Flutter

QUESTION

Why does changing the background color of the navigation bar in Cupertino App change the height?

Asked 2022-Mar-16 at 13:19

I have a widget demonstrating the rendering of a Flutter app. As it's written below, the text is visible right underneath the navigationBar. However, if you comment out the backgroundColor, it becomes invisible. Why is that?

1import 'package:flutter/cupertino.dart';
2import 'package:flutter/material.dart';
3
4void main() {
5  runApp(const MyApp());
6}
7
8class MyApp extends StatelessWidget {
9  const MyApp({Key? key}) : super(key: key);
10
11  @override
12  Widget build(BuildContext context) {
13    return CupertinoApp(
14      home: CupertinoPageScaffold(
15        navigationBar: const CupertinoNavigationBar(
16          middle: Text("Settings"),
17          previousPageTitle: "Back",
18          backgroundColor: Colors.blue,
19        ),
20        child: Column(
21          children: const <Widget>[
22            Text("Hello World!"),
23          ],
24        ),
25      ),
26    );
27  }
28}
29
30

Without blue color: Image without blue color

With blue color: Image with blue color

ANSWER

Answered 2022-Mar-16 at 13:19

The height is not changing with the backgroundColor, here's what CupertinoPageScaffold's documentation says:

Content can slide under the navigationBar when they're translucent. In that case, the child's BuildContext's MediaQuery will have a top padding indicating the area of obstructing overlap from the navigationBar.

This is why your text is hidden, it's simply going under the bar when its color is translucent. By using Colors.blue you will have an opaque color.

You can try by using backgroundColor: Colors.transparent the result will be the same as putting no color.

To fix this behavior you can wrap your Column with a SafeArea widget:

copy icondownload icon

1import 'package:flutter/cupertino.dart';
2import 'package:flutter/material.dart';
3
4void main() {
5  runApp(const MyApp());
6}
7
8class MyApp extends StatelessWidget {
9  const MyApp({Key? key}) : super(key: key);
10
11  @override
12  Widget build(BuildContext context) {
13    return CupertinoApp(
14      home: CupertinoPageScaffold(
15        navigationBar: const CupertinoNavigationBar(
16          middle: Text("Settings"),
17          previousPageTitle: "Back",
18          backgroundColor: Colors.blue,
19        ),
20        child: Column(
21          children: const <Widget>[
22            Text("Hello World!"),
23          ],
24        ),
25      ),
26    );
27  }
28}
29
30class MyApp extends StatelessWidget {
31  const MyApp({Key? key}) : super(key: key);
32
33  @override
34  Widget build(BuildContext context) {
35    return CupertinoApp(
36      home: CupertinoPageScaffold(
37        navigationBar: const CupertinoNavigationBar(
38          middle: Text("Settings"),
39          previousPageTitle: "Back",
40        ),
41        child: SafeArea(
42          child: Column(
43            children: const <Widget>[
44              Text("Hello World!"),
45            ],
46          ),
47        ),
48      ),
49    );
50  }
51}
52

Source https://stackoverflow.com/questions/71490932