Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions section_2/dart_basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
## null-safety対応版 ※変更があるもののみ  

## Dartの基礎1(null safety対応版)  
1-4. リスト、Set、Map: https://dartpad.dartlang.org/89679f169bcf0ff4fc4d82220c984d34  
1-4. リスト、Set、Map: https://dartpad.dartlang.org/89679f169bcf0ff4fc4d82220c984d34

## Dartの基礎2
2-1. 関数: https://dartpad.dev/38278c3c478d6d7ec7cac9aa445211d2
Expand All @@ -57,4 +57,4 @@
3-3. Enum: https://dartpad.dev/cfc6555a570a22394020e03d46f4c19f
3-4. 非同期処理: https://dartpad.dev/aa9a88ee331ed20feac08692dd1717e5   

演習3の解答例: https://dartpad.dev/f9dfd157c213ce70dc871c140c976d21
演習3の解答例: https://dartpad.dev/f9dfd157c213ce70dc871c140c976d21
4 changes: 2 additions & 2 deletions section_3/1_simple_app/1-2_pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -29,7 +29,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3

english_words: ^3.1.5 # 追記
english_words: ^4.0.0 # 追記

dev_dependencies:
flutter_test:
Expand Down
4 changes: 2 additions & 2 deletions section_3/1_simple_app/exercise1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:flutter/material.dart';

void main() => runApp(MyApp()); // 引数のWidgetが画面いっぱいに表示される

List<String> generateHello({int start, int n}){
List<String> generateHello({int? start, int? n}){
var _hs = <String>[];
for (int i=start; i<start+n; i++){
for (int? i = start; i! < start! + n!; i++){
_hs.add("Hello!" + i.toString());
}
return _hs;
Expand Down
4 changes: 2 additions & 2 deletions section_3/1_simple_app/model_answer1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:flutter/material.dart';

void main() => runApp(MyApp()); // 引数のWidgetが画面いっぱいに表示される

List<String> generateHello({int start, int n}){
List<String> generateHello({int? start, int? n}){
var _hs = <String>[];
for (int i=start; i<start+n; i++){
for (int? i = start; i! < start! + n!; i++){
_hs.add("Hello!" + i.toString());
}
return _hs;
Expand Down
6 changes: 4 additions & 2 deletions section_3/3_interactive/3-1_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ class _MyFormState extends State<MyForm> {
fontSize: 30.0,
),
),
FlatButton( // 一番シンプルなボタン
ElevatedButton( // 一番シンプルなボタン
onPressed: _handlePressed,
color: Colors.blue,
style: ElevatedButton.styleFrom(
primary: Colors.blue,
),
child: Text(
"いいね!",
style: TextStyle(
Expand Down
12 changes: 6 additions & 6 deletions section_3/4_transition/4-2_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ class _MainPageState extends State<MainPage> {

class TabPage extends StatelessWidget {

final IconData icon;
final String title;
final IconData? icon;
final String? title;

const TabPage({Key key, this.icon, this.title}) : super(key: key);
const TabPage({Key? key, this.icon, this.title}) : super(key: key);

@override
Widget build(BuildContext context) {
final TextStyle textStyle = Theme.of(context).textTheme.headline4; // 文字のスタイル
final TextStyle? textStyle = Theme.of(context).textTheme.headline4; // 文字のスタイル
return Center(
child:Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(icon, size: 72.0, color: textStyle.color),
Text(title, style: textStyle),
Icon(icon, size: 72.0, color: textStyle!.color),
Text(title!, style: textStyle),
],
),
);
Expand Down
4 changes: 2 additions & 2 deletions section_4/main_fb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _MyHomePageState extends State<MyHomePage> {
stream: FirebaseFirestore.instance.collection("dogs").snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return LinearProgressIndicator();
return _buildList(snapshot.data.docs);
return _buildList(snapshot.data!.docs);
},
);
}
Expand All @@ -55,7 +55,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

Widget _buildListItem(DocumentSnapshot snap) {
Map<String, dynamic> data = snap.data();
final Map<String, dynamic> data = snap.data() as Map<String, dynamic>;

return Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical:9.0),
Expand Down
6 changes: 3 additions & 3 deletions section_4/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -28,9 +28,9 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
cloud_firestore: ^2.2.2 #追記
firebase_core: ^1.3.0 #追記

firebase_core : ^0.5.0 # 追記
cloud_firestore: ^0.14.0+1 # 追記

dev_dependencies:
flutter_test:
Expand Down
5 changes: 4 additions & 1 deletion section_5/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# Override Firebase SDK Version
$FirebaseSDKVersion = '7.11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

Expand Down Expand Up @@ -77,7 +80,7 @@ target 'Runner' do
pod name, :path => File.join(symlink, 'ios')
end

pod 'Firebase/MLVisionFaceModel' # 追記
pod 'GoogleMLKit/FaceDetection' # 追記
end

post_install do |installer|
Expand Down
21 changes: 10 additions & 11 deletions section_5/main_mlkit.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:firebase_ml_vision/firebase_ml_vision.dart';
import 'package:google_ml_kit/google_ml_kit.dart';

void main() {
runApp(MyApp());
Expand All @@ -29,10 +28,10 @@ class FaceFinder extends StatefulWidget {
}

class _FaceFinderState extends State<FaceFinder> {
File _imageFile;
Size _imageSize;
List<Face> _faceResults;
final FaceDetector _faceDetector = FirebaseVision.instance.faceDetector();
File? _imageFile;
Size? _imageSize;
List<Face>? _faceResults;
final FaceDetector _faceDetector = GoogleMlKit.vision.faceDetector();
final ImagePicker _picker = ImagePicker();

void _getImageAndFindFace(ImageSource imageSource) async {
Expand All @@ -41,8 +40,8 @@ class _FaceFinderState extends State<FaceFinder> {
_imageSize = null;
});

final PickedFile pickedImage = await _picker.getImage(source: imageSource);
final File imageFile = File(pickedImage.path);
final PickedFile? pickedImage = await _picker.getImage(source: imageSource);
final File? imageFile = File(pickedImage!.path);

if (imageFile != null) {
_getImageSize(imageFile);
Expand Down Expand Up @@ -73,7 +72,7 @@ class _FaceFinderState extends State<FaceFinder> {
_faceResults = null;
});

final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(imageFile);
final InputImage visionImage = InputImage.fromFile(imageFile);

List<Face> results = await _faceDetector.processImage(visionImage);
setState(() {
Expand All @@ -86,7 +85,7 @@ class _FaceFinderState extends State<FaceFinder> {
constraints: BoxConstraints.expand(),
decoration: BoxDecoration(
image: DecorationImage(
image: Image.file(_imageFile).image,
image: Image.file(_imageFile!).image,
fit: BoxFit.contain,
),
),
Expand All @@ -100,7 +99,7 @@ class _FaceFinderState extends State<FaceFinder> {
),
),
)
: CustomPaint(painter: FaceBorderDrawer(_imageSize, _faceResults))
: CustomPaint(painter: FaceBorderDrawer(_imageSize!, _faceResults!))
);
}

Expand Down
10 changes: 5 additions & 5 deletions section_5/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -28,11 +28,11 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
firebase_core: ^1.18.0 #追記
google_ml_kit: ^0.11.0 #追記
image_picker: ^0.8.5+3 # 追記
camera: ^0.9.8+1 #追記

firebase_core: ^0.5.0 # 追記
firebase_ml_vision: ^0.9.6+2 # 追記
image_picker: ^0.6.0 # 追記
camera: ^0.5.6+1 # 追記

dev_dependencies:
flutter_test:
Expand Down
27 changes: 13 additions & 14 deletions section_6/main.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'dart:io';

//google_ml_kitのをimport
import 'package:google_ml_kit/google_ml_kit.dart';
import 'package:intl/intl.dart';
import 'package:uuid/uuid.dart';
import 'package:path/path.dart';
import 'package:image_picker/image_picker.dart';

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_ml_vision/firebase_ml_vision.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';

Expand Down Expand Up @@ -38,7 +38,7 @@ class MainForm extends StatefulWidget {
class _MainFormState extends State<MainForm> {
String _name ="";
String _processingMessage = "";
final FaceDetector _faceDetector = FirebaseVision.instance.faceDetector(
final FaceDetector _faceDetector = GoogleMlKit.vision.faceDetector(
FaceDetectorOptions(
mode: FaceDetectorMode.accurate,
enableLandmarks: true,
Expand All @@ -52,17 +52,16 @@ class _MainFormState extends State<MainForm> {
_processingMessage = "Processing...";
});

final PickedFile pickedImage = await _picker.getImage(source: imageSource);
final File imageFile = File(pickedImage.path);
final PickedFile? pickedImage = await _picker.getImage(source: imageSource);
final File imageFile = File(pickedImage!.path);

if (imageFile != null) {
final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(imageFile);
final InputImage visionImage = InputImage.fromFile(imageFile);
List<Face> faces = await _faceDetector.processImage(visionImage);
if(faces.length > 0){
String imagePath = "/images/" + Uuid().v1() + basename(pickedImage.path);
StorageReference ref = FirebaseStorage.instance.ref().child(imagePath);
final StorageTaskSnapshot storedImage = await ref.putFile(imageFile).onComplete;
if(storedImage.error == null){
Reference ref = FirebaseStorage.instance.ref().child(imagePath);
final TaskSnapshot storedImage = await ref.putFile(imageFile);

final String downloadUrl = await storedImage.ref.getDownloadURL();
Face largestFace = findLargestFace(faces);

Expand All @@ -76,9 +75,9 @@ class _MainFormState extends State<MainForm> {
context,
MaterialPageRoute(builder: (context) => TimelinePage(),)
);
}

}
}


setState(() {
_processingMessage = "";
Expand Down Expand Up @@ -165,7 +164,7 @@ class TimelinePage extends StatelessWidget {
stream: FirebaseFirestore.instance.collection("smiles").orderBy("date", descending: true).limit(10).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return LinearProgressIndicator();
return _buildList(context, snapshot.data.docs);
return _buildList(context, snapshot.data!.docs);
},
);
}
Expand All @@ -181,7 +180,7 @@ class TimelinePage extends StatelessWidget {
}

Widget _buildListItem(BuildContext context, DocumentSnapshot snap) {
Map<String, dynamic> _data = snap.data();
final Map<String, dynamic> _data =snap.data()! as Map<String, dynamic>;
DateTime _datetime = _data["date"].toDate();
var _formatter = DateFormat("MM/dd HH:mm");
String postDate = _formatter.format(_datetime);
Expand Down
Loading