0

enter image description here

 import 'package:flutter/material.dart';
import 'package:habit_tracker/widgets/all_habits/top_bar_widget.allhabits.dart';

class AllHabitsScreenC extends StatelessWidget {
  const AllHabitsScreenC({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
     return Scaffold(
      backgroundColor: const Color(0xffeaeaf4),
      body: SafeArea(
        child: Column(
          children: [
            const TopBarAllhabitsW(),
            Container(width: 300,height: 20,color: Colors.black,),
            SizedBox(
              width: 300,
              height: 200,
              child: TextField()),
            Container(width: 300,height: 20,color: Colors.black,),
            const SizedBox(height: 20,),
          ],
        ),
      ),
    );
  }
}

topbar widget code

import 'package:flutter/material.dart';
import 'package:habit_tracker/utils/icons.dart';
import 'package:habit_tracker/screens/habit_adder.dart';
import 'package:habit_tracker/screens/one_habit_details.dart';

class TopBarAllhabitsW extends StatelessWidget {
  const TopBarAllhabitsW({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        InkWell(
          onTap: () {
            Navigator.push(
              context,
              MaterialPageRoute(
                  builder: (context) => const OneHabitScreenC()),
            );
          },
          child: const Padding(
            padding: EdgeInsets.all(5.0),
            child: Icon(
              Icons.verified_user,
              color: Colors.green,
            ),
          ),
        ),
        InkWell(
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => const HabitAdderScreenC()),
              );
            },
            customBorder: const CircleBorder(),
            child: const Padding(
              padding: EdgeInsets.all(5.0),
              child: Icon(
                IconsMy.info,
                color: Colors.grey,
              ),
            )),
      ],
    );
  }
}

main.dart code

    import 'package:flutter/material.dart';
import 'package:habit_tracker/screens/all_habits.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter/services.dart';

Future<void> main() async {
  //initialize hive
 // await Hive.initFlutter();
 // await Hive.openBox('userTercihleri');
  /* if(hiveReadData("tercih_text_size")=="myNull"){
    hiveWriteData("tercih_text_size", "22");
  }

  if(hiveReadData("tercih_date_format")=="myNull"){
    hiveWriteData("tercih_date_format", "G/A");
  }

  if(hiveReadData("tercih_font_style")=="myNull"){
    hiveWriteData("tercih_font_style", "Roboto");
  }

  if(hiveReadData("default-Color")=="myNull"){
    hiveWriteData("default-Color", "grey");
  } */

  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(
        statusBarIconBrightness: Brightness.dark,
        statusBarColor: Color(0xffeaeaf4)),
  );

  WidgetsFlutterBinding.ensureInitialized();
  final prefs = await SharedPreferences.getInstance();
  final showHome = prefs.getBool("showHome") ?? false;

  runApp(
    ProviderScope(
      child: MyApp(showHome: showHome),
    ),
  );
}

class MyApp extends StatelessWidget {
  final bool showHome;

  const MyApp({
    Key? key,
    required this.showHome,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
   // String fontStyle = hiveReadData("tercih_font_style");
    return MaterialApp(
     // localizationsDelegates: const [GlobalMaterialLocalizations],
      supportedLocales: const [Locale('en', 'US'), Locale('tr', 'TR')],
      theme: ThemeData(
        pageTransitionsTheme: const PageTransitionsTheme(builders: {
          TargetPlatform.android: CupertinoPageTransitionsBuilder(),
          TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
        }),
        textTheme:
      //  fontStyle=="Roboto"
        /*?*/ GoogleFonts.robotoTextTheme(Theme.of(context).textTheme)
       /*  :fontStyle=="Opensans"
        ?GoogleFonts.openSansTextTheme(Theme.of(context).textTheme)
        :fontStyle=="Montserrat"
        ?GoogleFonts.montserratTextTheme(Theme.of(context).textTheme)
        :GoogleFonts.quicksandTextTheme(Theme.of(context).textTheme) */
        
      ),
      debugShowCheckedModeBanner: false,
      home: showHome ? AllHabitsScreenC() : AllHabitsScreenC(),
    );
  }
}

I have some widgets inside scaffold>Safearea>Padding>Column>Widgets

Some wigdets have textfield inside here. But these textfields return grey screen . When I use Text("ExampleString") there is no grey screen. But When I use textfield or textformfild.

In my code the TopBarAllhabitsW() is working normal but TextField() returns grey screen.

I tried a lot of solutions method. But I did not find the correct solution. The grey screen returns only real device. There is no problem on the emulator. I am using textfield between black containers to see the grey screen is returns.

mesh
  • 174
  • 1
  • 1
  • 10
  • 1
    You need to include all code related to that UI. – Gwhyyy Feb 10 '23 at 15:14
  • 1
    However, this means that there is a layout issue in your app, and I'm sure Flutter will print that issue in the debug console with it's reason, before building the app, try to navigate over that page while you're in debug mode, and you will see what's wrong – Gwhyyy Feb 10 '23 at 15:15
  • I edited my code please look again. I don't understand where is the error. – mesh Feb 10 '23 at 15:19
  • there was no error on the terminal or debug console. – mesh Feb 10 '23 at 15:20
  • Does this answer your question? [Flutter textfield background color on focus](https://stackoverflow.com/questions/54307673/flutter-textfield-background-color-on-focus) – Elias Fazel Feb 10 '23 at 15:35
  • No, it's not my problem. thank you for your help – mesh Feb 10 '23 at 15:42

0 Answers0