showdatepicker flutter text color showing white unselect year white how solve it

huangapple go评论71阅读模式
英文:

showdatepicker flutter text color showing white unselect year white how solve it

问题

showDatePicker(
  context: context,
  // 当前状态的上下文
  initialDate: DateTime.now(),
  firstDate: DateTime(2000),
  // 不允许选择今天之前的日期:DateTime.now()
  lastDate: DateTime.now(),
)

颜色变更 showDatePicker(
  context: context,
  // 当前状态的上下文
  initialDate: DateTime.now(),
  firstDate: DateTime(2000),
  // 不允许选择今天之前的日期:DateTime.now()
  lastDate: DateTime.now(),
  builder: (BuildContext context, Widget? child) {
    return Theme(
      data: ThemeData(
        primarySwatch: Colors.grey,
        splashColor: Colors.black,
        textTheme: const TextTheme(
          subtitle1: TextStyle(color: Colors.black),
          button: TextStyle(color: Colors.black),
        ),
        hintColor: Colors.black,
        colorScheme: const ColorScheme.light(
          primary: Colors.blue,
          primaryVariant: Colors.black,
          secondaryVariant: Colors.black,
          onSecondary: Colors.black,
          onPrimary: Colors.white,
          surface: Colors.black,
          onSurface: Colors.black,
          secondary: Colors.black,
        ),
        dialogBackgroundColor: Colors.white,
      ),
      child: child ?? Text(""),
    );
  }
)
英文:

showDatePicker(
context: context,
//context of current state
initialDate: DateTime.now(),
firstDate: DateTime(2000),
//DateTime.now() - not to allow to choose before today.
lastDate: DateTime.now(),

)

color changing showDatePicker(
context: context,
//context of current state
initialDate: DateTime.now(),
firstDate: DateTime(2000),
//DateTime.now() - not to allow to choose before today.
lastDate: DateTime.now(),

    builder: (BuildContext context, Widget ?child) {
      return Theme(
        data: ThemeData(
          primarySwatch: Colors.grey,
          splashColor: Colors.black,
          textTheme: const TextTheme(
            subtitle1: TextStyle(color: Colors.black),
            button: TextStyle(color: Colors.black),
          ),
          hintColor: Colors.black,
          colorScheme: const ColorScheme.light(
              primary: Colors.blue,
              primaryVariant: Colors.black,
              secondaryVariant: Colors.black,
              onSecondary: Colors.black,
              onPrimary: Colors.white,
              surface: Colors.black,
              onSurface: Colors.black,
              secondary: Colors.black),
          dialogBackgroundColor: Colors.white,
        ),
        child: child ??Text(""),
      );
    }

)

答案1

得分: -1

showDatePicker(
  context: context,
  // 当前上下文
  initialDate: DateTime.now(),
  firstDate: DateTime(2000),
  // 不允许选择今天之前的日期 DateTime.now()
  lastDate: DateTime.now(),

  builder: (BuildContext context, Widget? child) {
    return Theme(
      data: ThemeData(
        primarySwatch: Colors.grey,
        splashColor: Colors.black,
        textTheme: const TextTheme(
          subtitle1: TextStyle(color: Colors.black),
          button: TextStyle(color: Colors.black),
        ),
        hintColor: Colors.black,
        colorScheme: const ColorScheme.light(
          primary: Colors.blue,
          primaryVariant: Colors.black,
          secondaryVariant: Colors.black,
          onSecondary: Colors.black,
          onPrimary: Colors.white,
          surface: Colors.black,
          onSurface: Colors.black,
          secondary: Colors.black,
        ),
        dialogBackgroundColor: Colors.white,
      ),
      child: child ?? Text(""),
    );
  }
)
英文:
  showDatePicker(
        context: context,
        //context of current state
        initialDate: DateTime.now(),
        firstDate: DateTime(2000),
        //DateTime.now() - not to allow to choose before today.
        lastDate: DateTime.now(),

    builder: (BuildContext context, Widget ?child) {
      return Theme(
        data: ThemeData(
          primarySwatch: Colors.grey,
          splashColor: Colors.black,
          textTheme: const TextTheme(
            subtitle1: TextStyle(color: Colors.black),
            button: TextStyle(color: Colors.black),
          ),
          hintColor: Colors.black,
          colorScheme: const ColorScheme.light(
              primary: Colors.blue,
              primaryVariant: Colors.black,
              secondaryVariant: Colors.black,
              onSecondary: Colors.black,
              onPrimary: Colors.white,
              surface: Colors.black,
              onSurface: Colors.black,
              secondary: Colors.black),
          dialogBackgroundColor: Colors.white,
        ),
        child: child ??Text(""),
      );
    }

)

huangapple
  • 本文由 发表于 2023年6月13日 19:01:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76464223.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定