flutter 为什么文本在导航前不呈现在正文中?

myzjeezk  于 2023-01-27  发布在  Flutter
关注(0)|答案(1)|浏览(100)

由于某种原因,文本小部件在我的新视图中不起作用
我有一个来自MaterialApp的命名导航:

routes: <String, WidgetBuilder>
'/home': (BuildContext context) => Home(),
'/recipes': (BuildContext context) => const Recetas(),

主页中的一切都很好,但文本小部件无法在我的应用程序中呈现任何文本

// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';
import 'package:naturale_app/constraits.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: kSecondaryColor,
      appBar: AppBar(
        backgroundColor: kPrimaryColor,
        title: const Text("Recetas"),
      ),
      body: Center(
        child: Container(
          decoration: BoxDecoration(
            color: kWhiteColor,
            borderRadius: BorderRadius.circular(10),
          ),
          child: const Text( // This doesn't Render
            "Recetas",
            style: TextStyle(
              color: kBlackColor,
              fontSize: 24,
              fontWeight: FontWeight.bold,
            ),
          ),
        ),
      ),
    );
  }
}

我有这个:Recetas Views

yjghlzjz

yjghlzjz1#

我认为这将是您的文本颜色的问题,无论是背景和文本有相同的颜色,检查您的kBlackColor颜色。

child: Container(
          decoration: BoxDecoration(
            color: kWhiteColor, //here 
            borderRadius: BorderRadius.circular(10),
          ),
          child: const Text( 
            "Recetas",
            style: TextStyle(
              color: kBlackColor, //and here the same as bg on color decleration,
              fontSize: 24,
              fontWeight: FontWeight.bold,
            ),
          ),
        ),

将文本颜色更改为黑色或其他颜色

style: TextStyle(
      color: Colors.black,

相关问题