1
resposta

Problemas na mudanca de estado da opacidade

erro: The getter 'opacidade' isn't defined for the type 'MyHomePage'. Try importing the library that defines 'opacidade', correcting the name to the name of an existing getter, or defining a getter or field named 'opacidade'.

import 'package:flutter/material.dart'; import 'package:alura_curso/app/task.dart';

void main() { runApp(MyApp()); }

class MyApp extends StatefulWidget { MyApp({Key? key}) : super(key: key);

@override State createState() => _MyAppState(); }

class _MyAppState extends State { bool opacidade = true; @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent), useMaterial3: true, ), home: const MyHomePage(title: 'Projeto flutter alura'), ); } }

class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title});

final String title;

@override State createState() => _MyHomePageState(); }

class _MyHomePageState extends State { String way = 'assets/images'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: AnimatedOpacity( duration: const Duration(milliseconds: 2000), opacity: widget.opacidade ? 1.0 : 0.0, child: ListView( scrollDirection: Axis.vertical, reverse: true, children: [ Task("Task 1", '$way/mascote.png', 4), Task('Task 2', '$way/meditar.jpeg', 3), Task('Task 3', '$way/livro.jpeg', 5), Task('Task 4', '$way/jogar.jpeg', 1), ], ), ), floatingActionButton: FloatingActionButton( onPressed: () { setState(() { widget.opacidade = !widget.opacidade; }); }, child: const Icon(Icons.add), ), ); } }

1 resposta

problema resolvido

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software