update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
51
.config/Code/User/History/-2e064889/dAFd.dart
Normal file
51
.config/Code/User/History/-2e064889/dAFd.dart
Normal file
|
@ -0,0 +1,51 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
void main(){
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget{
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return ChangeNotifierProvider(
|
||||
create: (context) => MyAppState(),
|
||||
child: MaterialApp(
|
||||
title: 'First App',
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green)
|
||||
),
|
||||
home: const MyHomePage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyAppState extends ChangeNotifier{
|
||||
var counter = 0;
|
||||
}
|
||||
|
||||
class MyHomePage extends StatelessWidget{
|
||||
const MyHomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
var appState = context.watch<MyAppState>();
|
||||
var sCount = appState.counter.toString();
|
||||
|
||||
return const Scaffold(
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('count: '),
|
||||
Text(sCount),
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue