这里改了主题颜色为白色。报错

来源:4-6 自定义AppBar与登录动效设计与实现

额sdfsdfsdf

2021-05-07

但是我跟你一样报错
Failed assertion: line 598 pos 15: ‘textSelectionHandleColor != null’: is not true.

import 'package:flutter/material.dart';

const MaterialColor white = const MaterialColor(
    0xFFFFFFFF,
    <int, Color>{
      50: Color(0xFFFFFFFF),
      100: Color(0xFFFFFFFF),
      200: Color(0xFFFFFFFF),
      400: Color(0xFFFFFFFF),
      500: Color(0xFFFFFFFF),
      600: Color(0xFFFFFFFF),
      700: Color(0xFFFFFFFF),
      800: Color(0xFFFFFFFF),
      900: Color(0xFFFFFFFF),
    },
);
//主色调
const MaterialColor primary = const MaterialColor(
  0xfffb7299,
  const <int,Color>{50:const Color(0xffff9db5)},
);

这个是我color的代码

这个 main的代码

import 'package:bibi_app/util/color.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: white,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home:RegistrationPage(),
    )

感觉没有错啊 怎么报错了Failed assertion: line 598 pos 15: ‘textSelectionHandleColor != null’: is not true.

写回答

1回答

CrazyCodeBoy

2021-05-08

修改下SDK的兼容范围,可参考下这个问答:

https://coding.imooc.com/learn/questiondetail/vZnjEY77vvVY72Wd.html


0
4
CrazyCodeBoy
回复
额sdfsdfsdf
好的。
2021-05-13
共4条回复

Flutter高级进阶实战-仿哔哩哔哩-掌握Flutter高阶技能

一次性掌握Flutter高阶技能+商业级复杂项目架构设计与开发方案

1723 学习 · 870 问题

查看课程