Итак, в основном я создал виджет, который получает 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)
],
)
],
)
);
}
}
lesson.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, потому что именно там я вызываю Timetable с помощью данные:
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 Я новичок, чтобы трепетать, так что извините за этот тупой вопрос, но я не мог понять это сам.