Skip to content

Get Snackbar function isn't working #3420

@tedijumadi

Description

@tedijumadi

Hey, I just updated Flutter to version 3.38.1 and the dependency “get” version ^4.7.2, and now my get snackbar function isn't working. Can you help me?

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:hazard_komik/test.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: TextScreen(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Center(
            child: GestureDetector(
                onTap: () {
                  Get.snackbar("OK", "Snackbar Show");
                  print("Snackbar Print");
                },
                child: Container(
                    decoration: BoxDecoration(color: Colors.green),
                    child: Padding(
                      padding: const EdgeInsets.symmetric(
                          horizontal: 20, vertical: 10),
                      child: Text(
                        "Button Snackbar",
                        style: TextStyle(color: Colors.white),
                      ),
                    ))),
          )
        ],
      ),
    );
  }
}

I/flutter ( 5409): Snackbar Print
E/flutter ( 5409): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: No Overlay widget found.
E/flutter ( 5409): Some widgets require an Overlay widget ancestor for correct operation.
E/flutter ( 5409): The most common way to add an Overlay to an application is to include a MaterialApp, CupertinoApp or Navigator widget in the runApp() call.
E/flutter ( 5409): The context from which that widget was searching for an overlay was:
E/flutter ( 5409):   _Theater

Flutter Version:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.38.1, on Microsoft Windows
[Version 10.0.26200.7171], locale id-ID)
[√] Windows Version (11 Home 64-bit, 25H2, 2009)
[√] Android toolchain - develop for Android devices (Android
SDK version 36.1.0)
[X] Chrome - develop for the web (Cannot find Chrome
executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a
Chrome executable.
[√] Visual Studio - develop Windows apps (Visual Studio
Community 2022 17.14.9 Preview 1.0)
[√] Connected device (4 available)
[√] Network resources

Getx Version:
get: ^4.7.2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions