import 'package:flutter/material.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(
title: 'Malaria Meter',
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({required this.title});
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late List<GDPData> _chartData;
PanelController _panelController = PanelController();
@override
void initState() {
_chartData = getChartData();
super.initState();
}
void togglePanel() => _panelController.isPanelOpen
? _panelController.close()
: _panelController.open();
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return SafeArea(
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.red.shade300,
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {},
),
title: Text(
widget.title,
),
),
body: SlidingUpPanel(
controller: _panelController,
maxHeight: size.height * 0.8,
minHeight: size.height * 0.05,
body: Center(
child: Text("Ini adalah body"),
),
panelBuilder: (controller) {
return SingleChildScrollView(
controller: controller,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: togglePanel,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
height: 10,
width: 60,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.grey,
),
),
),
),
Container(
padding: EdgeInsets.all(25),
child: Text("Ini adalah item 1"),
),
Container(
child: SafeArea(
child: Scaffold(
body: SfCartesianChart(
series: <ChartSeries>[
BarSeries<GDPData, String>(
dataSource: _chartData,
xValueMapper: (GDPData gdp, _) => gdp.continent,
yValueMapper: (GDPData gdp, _) => gdp.gdp,
)
],
primaryXAxis: CategoryAxis(),
)),
),
),
],
),
);
},
borderRadius: BorderRadius.vertical(top: Radius.circular(25)),
),
),
);
}
List<GDPData> getChartData() {
final List<GDPData> chartData = [
GDPData('Oceania', 1600),
GDPData('Africa', 2490),
GDPData('S America', 2900),
GDPData('Europe', 23050),
GDPData('N America', 24880),
GDPData('Asia', 34390),
];
return chartData;
}
}
class GDPData {
GDPData(this.continent, this.gdp);
final String continent;
final double gdp;
}