jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.39k stars 1.63k forks source link

ChangeThemeMode Error UI. #3149

Open cbahai opened 4 months ago

cbahai commented 4 months ago

Describe the bug ChangeThemeMode Error UI.

import 'package:flutter/material.dart';
import 'package:get/get.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      themeMode: ThemeMode.system,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Theme Switcher', style: Get.textTheme.bodyLarge),
        // title: Text('Theme Switcher'), // it is ok.
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Press the button to toggle theme mode.', style: Get.textTheme.bodyLarge),
            // Text('Press the button to toggle theme mode.'),  // it is ok.
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                Get.changeThemeMode(Get.isDarkMode ? ThemeMode.light : ThemeMode.dark);
              },
              child: Text('Toggle Theme Mode', style: Get.textTheme.bodyLarge),
              // child: Text('Toggle Theme Mode'),  // it is ok.
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots image

--------- tap Toggle Theme Mode Button, text style not change. -------------

image

Flutter Version: Flutter 3.19.6 • channel stable • git@github.com:flutter/flutter.git Framework • revision 54e66469a9 (3 months ago) • 2024-04-17 13:08:03 -0700 Engine • revision c4cd48e186 Tools • Dart 3.3.4 • DevTools 2.31.1

Getx Version: get: ^4.6.6

Describe on which device you found the bug: iPhone 15, iOS17.4