import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../models/business.dart'; class ShopBulletin extends StatefulWidget { final Business business; const ShopBulletin(this.business, {Key key}): super(key: key); @override State createState() => ShopBulletinState(); } class ShopBulletinState extends State { double sideSpace = 0; double mainSpace = 1200; @override Widget build(BuildContext context) { if (MediaQuery.of(context).size.width <= 1200) { mainSpace = MediaQuery.of(context).size.width; sideSpace = 0; } else { mainSpace = 1200; sideSpace = (MediaQuery.of(context).size.width - 1200) / 2; } if (widget.business.bulletin != null && widget.business.bulletin.isNotEmpty) { return Container( margin: EdgeInsets.only(bottom: 12), child: Row( children: [ Container( width: sideSpace, ), Expanded( child: Container( padding: EdgeInsets.only(top: 10, left: 16.0, right: 16.0, bottom: 10.0), child: Text( '${widget.business.bulletin}', overflow: TextOverflow.ellipsis, maxLines: 3, style: TextStyle( color: Colors.white, ), ), decoration: BoxDecoration( color: Colors.orangeAccent, border: Border.all( color: Colors.red[500], width: 1.0, ), borderRadius: BorderRadius.all(Radius.circular(16)), ), ), ), Container( width: sideSpace, ), ], ), ); } return SizedBox.shrink(); } }