flutter - Flutter 如何正确显示带有阴影的矩阵
问题描述
所以基本上我做了一个小部件来获取这个final List<List<Map>> _timetable;
。
import 'package:flutter/material.dart';
import 'lesson.dart';
class Timetable extends StatelessWidget {
final List<List<Map>> _timetable;
Timetable(this._timetable);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Timetable"),
),
body: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
for (var lessons in _timetable)
Column(
children: <Widget>[
for (var info in lessons)
lesson(info)
],
)
],
)
);
}
}
课程.dart:
import 'package:flutter/material.dart';
class lesson extends StatelessWidget {
Map info = Map();
lesson(this.info);
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Center(
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1.0,
color: info.containsKey("color")
? info["color"]
: Colors.purple[900],
),
boxShadow: [
BoxShadow(
color: info.containsKey("color")
? info["color"]
: Colors.purple[900],
blurRadius: MediaQuery.of(context).size.height * 0.01, // has the effect of softening the shadow
spreadRadius: MediaQuery.of(context).size.height * 0.005, // has the effect of extending the shadow
offset: Offset(
0.0, // horizontal, move right 10
0.0, // vertical, move down 10
),
)
],
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
child: Padding(
padding: EdgeInsets.all(2.0),
child: Column(
children: <Widget>[
Text(info["lesson"]),
Text(info["teacher"])
],
))),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
],
);
}
}
和 main.dart 因为这是我用数据调用时间表的地方:
import 'package:flutter/material.dart';
import 'package:schoolify/screens/timetable/timetable.dart';
void main() {
runApp(MyApp());
}
List<List<Map>> days = List<List<Map>>();
List<Map> monday = List<Map>();
List<Map> tuesday = List<Map>();
List<Map> wednesday = List<Map>();
List<Map> thursday = List<Map>();
List<Map> friday = List<Map>();
List<Map> saturday = List<Map>();
List<Map> sunday = List<Map>();
Map german = Map();
Map english = Map();
Map mathematics = Map();
Map free = Map();
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
german["teacher"] = "Hr. DE";
german["lesson"] = "DE";
german["color"] = Colors.blue;
english["teacher"] = "Mr. EN";
english["lesson"] = "EN";
english["color"] = Colors.pinkAccent;
mathematics["teacher"] = "Fr. MA";
mathematics["lesson"] = "MA";
mathematics["color"] = Colors.green[700];
free["teacher"] = "no one";
free["lesson"] = "none";
free["color"] = Colors.redAccent;
monday.add(english);
monday.add(german);
monday.add(english);
monday.add(german);
monday.add(mathematics);
tuesday.add(german);
tuesday.add(german);
tuesday.add(german);
tuesday.add(german);
tuesday.add(german);
wednesday.add(english);
wednesday.add(german);
wednesday.add(english);
wednesday.add(german);
wednesday.add(mathematics);
thursday.add(english);
thursday.add(german);
thursday.add(english);
thursday.add(german);
thursday.add(mathematics);
friday.add(english);
friday.add(german);
friday.add(english);
friday.add(german);
friday.add(mathematics);
saturday.add(english);
saturday.add(german);
saturday.add(english);
saturday.add(german);
saturday.add(mathematics);
sunday.add(free);
sunday.add(free);
sunday.add(free);
sunday.add(free);
sunday.add(free);
sunday.add(free);
sunday.add(free);
sunday.add(free);
sunday.add(free);
days.add(monday);
days.add(tuesday);
days.add(wednesday);
days.add(thursday);
days.add(friday);
days.add(saturday);
days.add(sunday);
return MaterialApp(
home: Timetable(days),
theme: ThemeData(),
);
}
}
但结果是:
所以请帮助我,让阴影只在课外 PS我是新手,很抱歉这个愚蠢的问题,但我自己无法弄清楚。
解决方案
推荐阅读
- haskell - Haskell 在防止缓冲区溢出方面有多安全?
- firebase - 如何仅授予管理员帐户访问权限以创建新帐户,而不是在创建新帐户后将其注销?
- javascript - 使用 JSDoc 从另一个模块引用 @class
- java - 如何使用 LSP4J 在 Java 中重用现有的语言服务器 (LSP)
- microsoft-graph-api - 扩展属性和扩展属性有什么区别
- google-apps-script - Apple 中的 dopost(e) 功能问题
- selenium - Python selenium 从下拉列表中复制所有选项
- javascript - include[].duplicating: true 在续集中有什么作用?
- python - “AssertionError: push() 期望移动是合法的”,显示一个不是传入的棋盘
- wordpress - 在 WordPress 网站上出现重复的 403 错误