Skip to content

Instantly share code, notes, and snippets.

@gabrielaraujoz
Last active October 26, 2022 19:11
Show Gist options
  • Save gabrielaraujoz/9b165c9d80297fa2ba85161d0aa05ef4 to your computer and use it in GitHub Desktop.
Save gabrielaraujoz/9b165c9d80297fa2ba85161d0aa05ef4 to your computer and use it in GitHub Desktop.
Flutter Theme Demo - Part 1

Flutter Theme Demo - Part 1

Created with <3 with dartpad.dev.

// 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 Theme Demo - Part 1'),
);
}
}
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> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.amber,
appBar: AppBar(
title: Text(widget.title),
backgroundColor: Colors.black,
),
body: ListView(
children: [
Padding(
padding: const EdgeInsets.all(40),
child: Text(
'Esta é a cor de background: Colors.amber ${Colors.amber}',
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 12),
child: Card(
elevation: 3,
color: Colors.deepOrange,
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
children: [
const Text(
'You have pushed the button this many times:',
),
Text(
'0',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 12),
height: 300,
child: Card(
elevation: 3,
color: Colors.deepOrange,
child: Padding(
padding: const EdgeInsets.all(24),
child: ListView(
scrollDirection: Axis.horizontal,
children: const [
Card(
elevation: 3,
color: Colors.white,
child: Padding(
padding: EdgeInsets.all(24),
child: Text(
'Conteudo do card 1',
),
),
),
SizedBox(width: 12),
Card(
elevation: 3,
color: Colors.white,
child: Padding(
padding: EdgeInsets.all(24),
child: Text(
'Conteudo do card 2',
),
),
),
SizedBox(width: 12),
Card(
elevation: 3,
color: Colors.white,
child: Padding(
padding: EdgeInsets.all(24),
child: Text(
'Conteúdo do card 3',
),
),
),
],
),
),
),
),
Theme(
data: ThemeData.from(
colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.green),
),
child: Center(
child: Container(
width: 100,
height: 100,
color: Theme.of(context).colorScheme.primary,
),
),
),
const SizedBox(height: 20),
Theme(
data: ThemeData.from(
colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.green),
),
child: Builder(
builder: (BuildContext context) {
return Center(
child: Container(
width: 100,
height: 100,
color: Theme.of(context).colorScheme.primary,
),
);
},
),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Theme(
data: ThemeData.from(
colorScheme:
ColorScheme.fromSwatch(primarySwatch: Colors.green),
),
child: Center(
child: Container(
width: 100,
height: 100,
color: Theme.of(context).colorScheme.primary,
),
),
),
const SizedBox(height: 20),
Theme(
data: ThemeData.from(
colorScheme:
ColorScheme.fromSwatch(primarySwatch: Colors.green),
),
child: Builder(
builder: (BuildContext context) {
return Center(
child: Container(
width: 100,
height: 100,
color: Theme.of(context).colorScheme.primary,
),
);
},
),
),
],
),
Column(
children: [
Theme(
data: ThemeData.from(
colorScheme:
ColorScheme.fromSwatch(primarySwatch: Colors.green),
),
child: Center(
child: Container(
width: 100,
height: 100,
color: Colors
.green, //aqui eu fiz um ajuste para poder fazer a foto bonitinha :)
),
),
),
const SizedBox(height: 20),
Theme(
data: ThemeData.from(
colorScheme:
ColorScheme.fromSwatch(primarySwatch: Colors.green),
),
child: Builder(
builder: (BuildContext context) {
return Center(
child: Container(
width: 100,
height: 100,
color: Theme.of(context).colorScheme.primary,
),
);
},
),
),
],
),
],
),
const SizedBox(height: 20),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment