This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var dayOfWeek = 'Monday'; | |
| var dayNumber = switch (dayOfWeek) { | |
| 'Monday' => 1, | |
| 'Tuesday' => 2, | |
| 'Wednesday' => 3, | |
| 'Thursday' => 4, | |
| 'Friday' => 5, | |
| 'Saturday' => 6, | |
| 'Sunday' => 7, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp( | |
| MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| home: Scaffold( | |
| body: Center( | |
| child: FutureBuilder( | |
| future: Future<String>.delayed( | |
| const Duration(seconds: 3), () => 'Hello World!'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| final colors = [ | |
| const Color.fromARGB(255, 255, 0, 0), | |
| const Color.fromARGB(255, 0, 255, 0), | |
| const Color.fromARGB(255, 0, 0, 255), | |
| ]; | |
| void main() { | |
| runApp( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp( | |
| MaterialApp( | |
| theme: ThemeData( | |
| useMaterial3: true, | |
| colorScheme: ColorScheme.fromSeed(seedColor: Colors.red) | |
| .copyWith(surface: Colors.pink), | |
| cardTheme: CardTheme( | |
| shape: RoundedRectangleBorder( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp( | |
| MaterialApp( | |
| theme: ThemeData( | |
| fontFamily: 'Roboto', | |
| useMaterial3: true, | |
| textTheme: const TextTheme( | |
| bodyMedium: TextStyle( | |
| color: Colors.red, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp( | |
| MaterialApp( | |
| theme: ThemeData( | |
| brightness: Brightness.light, | |
| useMaterial3: true, | |
| colorScheme: ColorScheme.fromSwatch( | |
| primarySwatch: Colors.blue, | |
| ).copyWith( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| ThemeData lightTheme = ThemeData( | |
| brightness: Brightness.light, | |
| colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue), | |
| ); | |
| ThemeData darkTheme = ThemeData( | |
| brightness: Brightness.dark, | |
| colorScheme: ColorScheme.fromSeed( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'dart:async'; | |
| ///🎮 Controller | |
| ///This class handles business logic and notifies listeners when the state changes. | |
| ///In this example, the controller holds the state, which is the counter. | |
| ///The state is mutable | |
| class CounterController extends ChangeNotifier { | |
| CounterController(this.apiService); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| import 'package:test/test.dart'; | |
| class User { | |
| final String displayName; | |
| final String email; | |
| User(this.displayName, this.email); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ✅ 1. Nested ternaries | |
| Widget _mainDisplay1( | |
| AsyncSnapshot<ValueNotifier<int>> snapshot, BuildContext context) => | |
| snapshot.hasData | |
| ? Column( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| const Text( | |
| 'You have pushed the button this many times:', | |
| ), |