Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'monumento.dart';
- import 'package:http/http.dart' as http;
- import 'dart:convert';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- debugShowCheckedModeBanner: false,
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- visualDensity: VisualDensity.adaptivePlatformDensity,
- ),
- home: HomeScreen(),
- );
- }
- }
- class HomeScreen extends StatefulWidget {
- @override
- _HomeScreenState createState() => _HomeScreenState();
- }
- class _HomeScreenState extends State<HomeScreen> {
- String risultato = '';
- List<Monumento> monumenti = List<Monumento>();
- @override
- void initState() {
- monumentiGet();
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Column(
- children: <Widget>[
- ClipPath(
- clipper: MyClipper(),
- child: Container(
- height: 350,
- width: double.infinity,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topRight,
- end: Alignment.bottomLeft,
- colors: [Color(0xFF890000), Color(0xFF520000)]),
- image: DecorationImage(
- image: NetworkImage(
- 'xxx'),
- ),
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 20),
- height: 80,
- width: double.infinity,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(25),
- border: Border.all(
- color: Color(0xFF676767),
- )),
- child: Padding(
- padding: const EdgeInsets.all(12.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: <Widget>[
- Text(
- 'Oggi a Ferentino ci sono 18 gradi',
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
- Icon(Icons.wb_sunny)
- ],
- ),
- ),
- ),
- Container(
- height: 100,
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: ListView.builder(
- scrollDirection: Axis.horizontal,
- itemCount: monumenti.length,
- itemBuilder: (BuildContext context, int index) {
- return Card(
- elevation: 2,
- child: ListTile(
- onTap: (){},
- leading: Image.network(monumenti[index].immagine),
- title: Text(monumenti[index].nomeMonumento),
- subtitle: Text(monumenti[index].nomeMonumento),
- )
- );
- },
- ),
- ),
- )
- ],
- ),
- );
- }
- Future monumentiGet() async {
- final String url = 'xxx';
- try {
- http.get(url).then((res) {
- final resJson = json.decode(res.body);
- monumenti = resJson
- .map<Monumento>((mappa) => Monumento.fromMap(mappa))
- .toList();
- setState(() {
- risultato = res.body;
- monumenti = monumenti;
- });
- });
- } catch (errore) {
- setState(() {
- risultato = '';
- });
- }
- }
- }
- class MyClipper extends CustomClipper<Path> {
- @override
- Path getClip(Size size) {
- var path = Path();
- path.lineTo(0, size.height - 80);
- path.quadraticBezierTo(
- size.width / 2, size.height, size.width, size.height - 80);
- path.lineTo(size.width, 0);
- path.close();
- return path;
- }
- @override
- bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement