Joshua Singla
Joshua Singla

Reputation: 11

CupertinoTabScaffold showing a black screen

In my flutter app, I am trying to use CupertinoTabScaffold, but it just makes my entire physical emulator (Samsung galaxy s7) screen black.

Here is the code (from https://api.flutter.dev/flutter/cupertino/CupertinoTabBar-class.html?_gl which makes my screen black),

import 'package:flutter/cupertino.dart';

/// Flutter code sample for [CupertinoTabBar].

void main() => runApp(const CupertinoTabBarApp());

class CupertinoTabBarApp extends StatelessWidget {
  const CupertinoTabBarApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      theme: CupertinoThemeData(brightness: Brightness.light),
      home: CupertinoTabBarExample(),
    );
  }
}

class CupertinoTabBarExample extends StatelessWidget {
  const CupertinoTabBarExample({super.key});

  @override
  Widget build(BuildContext context) {
    return CupertinoTabScaffold(
      tabBar: CupertinoTabBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(icon: Icon(CupertinoIcons.star_fill), label: 'Favorites'),
          BottomNavigationBarItem(icon: Icon(CupertinoIcons.clock_solid), label: 'Recents'),
          BottomNavigationBarItem(
            icon: Icon(CupertinoIcons.person_alt_circle_fill),
            label: 'Contacts',
          ),
          BottomNavigationBarItem(icon: Icon(CupertinoIcons.circle_grid_3x3_fill), label: 'Keypad'),
        ],
      ),
      tabBuilder: (BuildContext context, int index) {
        return CupertinoTabView(
          builder: (BuildContext context) {
            return Center(child: Text('Content of tab $index'));
          },
        );
      },
    );
  }
}

Here is the output in AndroidStudio

Launching lib/main.dart on SM G930F in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Installing build/app/outputs/flutter-apk/app-debug.apk...
I/flutter (30031): [IMPORTANT:flutter/shell/platform/android/android_context_gl_impeller.cc(94)] Using the Impeller rendering backend (OpenGLES).
Debug service listening on ws://127.0.0.1:39913/7Uznt7dMBl8=/ws
Syncing files to device SM G930F...
I/Choreographer(30031): Skipped 179 frames!  The application may be doing too much work on its main thread.
I/zygote64(30031): Debugger is no longer active

I am using flutter 3.29.0

I don't really ask much questions about app development, so let me know what more information you need and I can add it to the question

I've tried running it on the Android Studio emulator, and it actually does work on that and it gives a correct result as per the image, so I think it's something to do with my physical emulator, I just don't know what exactly.

enter image description here

Upvotes: 0

Views: 23

Answers (0)

Related Questions