![]( )
import 'package:flutter/material.dart';
import 'package:untitled1/task_model2.dart';
class EstadoGeral extends InheritedWidget {
EstadoGeral({
Key? key,
required Widget child,
}) : super(key: key, child: child);
final List<TaksModel2> TaskListlegal = [
TaksModel2("https://th.bing.com/th/id/OIP.YAMi25QeI_ka-yP6BqlYfwHaLG?w=115&h=180&c=7&r=0&o=5&pid=1.7", 2.5, "Sabao em po",2 ),
TaksModel2("https://th.bing.com/th/id/OIP.YAMi25QeI_ka-yP6BqlYfwHaLG?w=115&h=180&c=7&r=0&o=5&pid=1.7", 2.5, "Sabao Liquido" ,2),
TaksModel2("https://th.bing.com/th/id/OIP.YAMi25QeI_ka-yP6BqlYfwHaLG?w=115&h=180&c=7&r=0&o=5&pid=1.7", 2.5, "Sabao Liquido" ,2),
TaksModel2("https://th.bing.com/th/id/OIP.YAMi25QeI_ka-yP6BqlYfwHaLG?w=115&h=180&c=7&r=0&o=5&pid=1.7", 2.5, "Sabao Liquido" ,2),
];
void InsereTarefa( String image, double valorUnit, String descricao, int quantidade ) {
TaskListlegal.add(TaksModel2(image, valorUnit, descricao, quantidade) );
}
static EstadoGeral of(BuildContext context) {
final EstadoGeral? result = context.dependOnInheritedWidgetOfExactType<EstadoGeral>();
assert(result != null, 'No Estado_geral found in context');
return result!;
}
@override
bool updateShouldNotify(EstadoGeral oldWidget) {
return oldWidget.TaskListlegal.length != TaskListlegal.length ;
}
}
import 'package:flutter/material.dart';
import 'package:untitled1/data.dart';
class HomeTrabalho extends StatefulWidget {
HomeTrabalho({Key? key}) : super(key: key);
@override
State<HomeTrabalho> createState() => _HomeTrabalhoState();
}
class _HomeTrabalhoState extends State<HomeTrabalho> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
title: const Text('Area de Trabalho'),
leading: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: Icon(Icons.chevron_left_outlined),
),
),
body: SingleChildScrollView(
child: Column(
children: [
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: "Informe o produto",
label: Text("Produto")),
style: TextStyle(
fontSize: 15,
),
),
Wrap(
runSpacing: 5.0,
spacing: 5.0,
children: EstadoGeral.of(context).TaskListlegal
),
SizedBox(
height: 20,
)
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
},
child: Icon(Icons.chat),
),
),
);
}
}
esse codigo esta apresendanto o seguinte erro, que apos reanalisar o codigo inteiro nao estou conseguindo resolver, poderiam me ajudar ? "The following assertion was thrown building HomeTrabalho(dirty, state: HomeTrabalhoState#0a19e): No Estadogeral found in context 'package:untitled1/data.dart': Failed assertion: line 23 pos 12: 'result != null'"