Skip to content

Instantly share code, notes, and snippets.

@fonkamloic
Last active September 27, 2021 06:44
Show Gist options
  • Save fonkamloic/a530b07bffdfbbee1c3e4fb3703389fd to your computer and use it in GitHub Desktop.
Save fonkamloic/a530b07bffdfbbee1c3e4fb3703389fd to your computer and use it in GitHub Desktop.
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MessageTile(),
);
}
}
class MessageTile extends StatelessWidget {
final userName = 'Mark';
final message = 'You have pushed the button this many times:';
final scaleFactor = 6.5;
@override
Widget build(BuildContext context) {
final lineLength = userName.length > message.length
? userName.length.toDouble()
: message.length.toDouble();
return Scaffold(
appBar: AppBar(
title: const Text('Testing'),
),
body: Container(
margin: const EdgeInsets.all(10),
padding: const EdgeInsets.all(5),
height: 70,
width: 300,
decoration: BoxDecoration(
color: Colors.grey,
border: Border.all(color: Colors.blueAccent),
borderRadius: const BorderRadius.all(
Radius.circular(10.0),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(userName),
SizedBox(
width: lineLength * scaleFactor,
child: const Divider(color: Colors.red),
),
Text(
message,
),
],
),
), // message container
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment