Skip to content

Instantly share code, notes, and snippets.

@frankyston
Forked from leonino/main.dart
Created February 27, 2023 20:13
Show Gist options
  • Save frankyston/5530de5a296fe90eaf6150e4e68acd6d to your computer and use it in GitHub Desktop.
Save frankyston/5530de5a296fe90eaf6150e4e68acd6d to your computer and use it in GitHub Desktop.
Draw Menu
// 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: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({
Key? key,
required this.title,
}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final controller = ScrollController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(MediaQuery.of(context).size.width.toFracao(48)),
decoration: const BoxDecoration(
color: Colors.black12,
),
child: const TextField(
decoration: InputDecoration(
label: Text("Informe qualquer coisa"),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(15)),
),
),
),
),
drawer: DrawWidget(),
floatingActionButton: FloatingActionButton(
onPressed: () {},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
class DrawWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
color: Colors.white,
),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width.toQuarto(3),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: 150,
color: Colors.red,
child: const Center(
child: CircleAvatar(maxRadius: 35, child: Text("MR")),
),
),
Expanded(
child: ListView(
children: const <Widget>[
ListTile(
title: Text("For Finance"),
leading: Icon(Icons.home),
),
ListTile(
title: Text("Contas"),
leading: Icon(Icons.business_sharp),
),
ListTile(
title: Text("Cartões"),
leading: Icon(Icons.credit_card),
),
ListTile(
title: Text("Lancamentos"),
leading: Icon(Icons.money_rounded),
),
ListTile(
title: Text("Relatorios"),
leading: Icon(Icons.document_scanner_sharp),
),
Divider(),
ListTile(
title: Text("Sonhos / Metas"),
leading: Icon(Icons.tag_sharp),
),
],
),
),
Column(
children: const [
Divider(),
ListTile(
title: Text("Sair"),
leading: Icon(Icons.logout_sharp),
),
],
),
],
),
);
}
}
extension Fracoes on num {
double toDecimo([int? parte]) => toFracao(10, parte);
double toNono([int? parte]) => toFracao(9, parte);
double toOitavo([int? parte]) => toFracao(8, parte);
double toSetimo([int? parte]) => toFracao(7, parte);
double toSexto([int? parte]) => toFracao(6, parte);
double toQuinto([int? parte]) => toFracao(5, parte);
double toQuarto([int? parte]) => toFracao(4, parte);
double toTerco([int? parte]) => toFracao(3, parte);
double toMetade([int? parte]) => toFracao(2, parte);
double toFracao(int partes, [int? parte]) {
parte = parte ?? 1;
parte = parte > partes || parte == 0 ? partes : parte;
return (this / partes) * parte;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment