Created
March 22, 2021 16:53
-
-
Save jaumard/c90eb14374ac3f90f154ff3a829df923 to your computer and use it in GitHub Desktop.
Simple layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(title), | |
), | |
body: Stack( | |
fit: StackFit.expand, | |
children: [ | |
Container( | |
child: FlutterLogo(), | |
color: Colors.grey, | |
), | |
Align( | |
child: Row( | |
children: [ | |
Padding( | |
padding: const EdgeInsets.all(32.0), | |
child: Container( | |
child: Text('SuperHost'), | |
color: Colors.amber, | |
), | |
), | |
Spacer(), | |
Padding( | |
padding: const EdgeInsets.all(32.0), | |
child: CustomCheckBox(), | |
), | |
], | |
), | |
alignment: Alignment.topCenter, | |
), | |
Align( | |
child: Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: Text('DOT HERE'), | |
), | |
alignment: Alignment.bottomCenter, | |
), | |
], | |
), | |
); | |
} | |
} | |
class CustomCheckBox extends StatefulWidget { | |
@override | |
CustomCheckBoxState createState() { | |
return CustomCheckBoxState(); | |
} | |
} | |
class CustomCheckBoxState extends State<StatefulWidget> { | |
bool checked = false; | |
@override | |
Widget build(BuildContext context) { | |
return InkWell( | |
//can be changed by images | |
child: Container(child: checked ? Text('checked') : Text('not checked')), | |
onTap: () { | |
setState(() { | |
checked = !checked; | |
}); | |
}, | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment